Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Test-Differences CPAN distribution.

Report information
The Basics
Id: 64487
Status: resolved
Priority: 0/
Queue: Test-Differences

People
Owner: Nobody in particular
Requestors: mark.zealey [...] webfusion.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.500
Fixed in: (no value)



Subject: Allow custom sort order
Hi Curtis, hope all's well with you in Amsterdam :-) I've just been trying to dump a hash where every key is a number and rather than the default cmp sort order I'd like to make it <=>. However, unfortunately I can't seem to do that because in eq_or_diff you localize $DD::Sortkeys to 1. Perhaps a new option like sortkeys => sub { DD-like-subroutine } would be nice to have? I think the only code change would be something like: local $Data::Dumper::Sortkeys = exists $options->{sortkeys} ? $options->{sortkeys} : 1; which would also allow the user to set Sortkeys to 0 if they so wished (not sure why anyone would want that though..) Mark
On Wed Jan 05 07:05:23 2011, mzealey wrote: Show quoted text
> Hi Curtis, hope all's well with you in Amsterdam :-) > > I've just been trying to dump a hash where every key is a number and > rather than the default cmp sort order I'd like to make it <=>. However, > unfortunately I can't seem to do that because in eq_or_diff you localize > $DD::Sortkeys to 1. Perhaps a new option like > > sortkeys => sub { DD-like-subroutine } > > would be nice to have? I think the only code change would be something like: > > local $Data::Dumper::Sortkeys = exists $options->{sortkeys} ? > $options->{sortkeys} : 1; > > which would also allow the user to set Sortkeys to 0 if they so wished > (not sure why anyone would want that though..) > > Mark
Hi Mark, Sorry it's taken me so long to get to this. Oh, and Amsterdam is lovely, thank you. (And we're hiring ;) I'm confused by your ticket. On one hand you say that I should let users have Sortkeys set to 0 if they so wished, but then you said you're not sure why anyone would want this behaviour you've proposed. Can you send me a test case so I can better understand this? :) Cheers, Curtis
Subject: Re: [rt.cpan.org #64487] Allow custom sort order
Date: Sat, 16 Apr 2011 16:49:54 +0300
To: bug-Test-Differences [...] rt.cpan.org
From: Mark Zealey <mark.zealey [...] webfusion.com>
Show quoted text
> Hi Mark, > > Sorry it's taken me so long to get to this. Oh, and Amsterdam is lovely, thank you. (And we're > hiring ;) > > I'm confused by your ticket. On one hand you say that I should let users have Sortkeys set to > 0 if they so wished, but then you said you're not sure why anyone would want this behaviour > you've proposed. Can you send me a test case so I can better understand this? :)
Well, I'm not sure why anyone would want to set it to 0 however there may be some use case I'm missing hence using ?: rather than || in the code I gave. In my case I wanted to dump the hash using a <=> sort order rather than cmp as every key was a number. In particular it was to do with pop3 messages and I was only expecting differences (if any) to occur at the end of the list. Obviously if you have differences with numbers 39, 40 and 41 the cmp sort order would display these as 39, 4, 40, 41, 5, 6, 7, ... which is a bit annoying especially when you get into the 100's and 1000's. Mark
Ah, thanks Mark. Now I understand and I've just uploaded it as 0.61 :) Cheers, Ovid