Re: strange sort order

2004-01-15 Thread Daniel Staal
--As off Wednesday, January 14, 2004 11:24 PM -0500, Daniel Staal is alleged to have said: my @a = unpack("C*", $a); my @b = unpack("C*", $b); This can also be done with a: my @a = split //, $a; # (That is a null pattern.) I'm not sure if split or unpack is faster, I'll have to benchma

Re: strange sort order

2004-01-15 Thread Rob Dixon
Daniel Staal wrote: > > > Oh no! Its slower! I wrote a function implementing what is > > described above and its actually slower (about 1/2 as slow) than > > that huge thing I posted earlier. Does anything stand out here as > > being inefficient? Here it is: > > (First glance stuff:) > > > sub comp

Re: strange sort order

2004-01-15 Thread Rob Dixon
Danl001 wrote: > > I do not have access to the sort operation. All I have is a file that is > "sorted" but I don't know exactly the mechanism by which it was sorted. > What I am trying to do is write a comparison function--given any two > lines in this file, return -1, 0, 1 as perl's cmp function d

Re: strange sort order

2004-01-14 Thread Daniel Staal
--As off Wednesday, January 14, 2004 10:48 PM -0500, Dan is alleged to have said: Oh no! Its slower! I wrote a function implementing what is described above and its actually slower (about 1/2 as slow) than that huge thing I posted earlier. Does anything stand out here as being inefficient? Here i

Re: strange sort order

2004-01-14 Thread Dan
danl001 wrote: Here, the first 10 characters correspond but then the second string runs out. Using our rule, we'd order ABC-MARKET before ABC-MARKET.ABC-MARKET, which is wrong. I guess I could try following that rule, but if the character position in the longer string that corresponds to the fi

Re: strange sort order

2004-01-14 Thread danl001
Daniel Staal wrote: Quick question: is this data more representative than the data in the first email? In particular, does set 4 from the first email actually exist, exactly as listed, anywhere? If this latter data is more representative I'd bet on ASCIIbetical ordering: Compare each string on

Re: strange sort order

2004-01-14 Thread Daniel Staal
--As off Wednesday, January 14, 2004 6:23 PM -0500, danl001 is alleged to have said: I'm thinking the way the file is sorted is something simple, yet something I don't recgonize! As a result, you'll see that my method is probably very over-complicated. I have also posted some more data that is re

strange sort order

2004-01-14 Thread danl001
Hello, I do not have access to the sort operation. All I have is a file that is "sorted" but I don't know exactly the mechanism by which it was sorted. What I am trying to do is write a comparison function--given any two lines in this file, return -1, 0, 1 as perl's cmp function does. I don't

Re: strange sort order

2004-01-14 Thread Rob Dixon
Dan Laflamme wrote: > > I have a file that appears to be somewhat sorted, but is not sorted > according to the traditional unix sort. I'll give some examples, and if > anyone recgonizes the way in which the file is sorted, please let me > know. Also, since I may have to write a comparator function

Re: strange sort order

2004-01-13 Thread Dan
g on ASCII comparison',$/,$/; for(sort keys %$sets) { print ' ',$_,$/; # ASCII sort (same as sort { $a cmp $b }) for(sort @{$sets->{$_}}) { print '',$_,$/; } print $/; } exit; Shawn -Original Message- From: Dan LaFlamme [mailto:[EMAIL PROTECTED] Sent:

strange sort order

2004-01-13 Thread Dan LaFlamme
Hi, I have a file that appears to be somewhat sorted, but is not sorted according to the traditional unix sort. I'll give some examples, and if anyone recgonizes the way in which the file is sorted, please let me know. Also, since I may have to write a comparator function for use on this "sort