in reply to Sorting binary
#!/usr/bin/perl -wl use strict; my @ints = (34, 0, 6, 9999, 1); print "@ints"; @ints = map {pack "n", $_ } @ints; # Pack the data @ints = sort @ints; # Sort lexically @ints = map {unpack "n", $_ } @ints; # Unpack it print "@ints";
However, there are quite a few caveats, such as dealing with negative numbers and hardware endianness. But, perhaps you could give a bit more detail about what you are trying to do before we go down those paths.
--
John.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
To John Re: Sorting binary
by Anonymous Monk on Mar 13, 2002 at 16:20 UTC |