[erlang-questions] sorting rules regarding bit strings
David Mercer
dmercer@REDACTED
Thu Apr 2 15:01:58 CEST 2009
On April 02, 2009, Ulf Wiger wrote:
> Maybe I'm just unusually dense today, but what are
> the sorting properties of bit strings?
. . .
> Well, I think I can see the pattern, but is this really
> what one wants?
The sort order seems right to me. When I write out the bit patterns it
might make it clear:
> [<<1>>, 00000001
> <<1>>, 00000001
> <<1:7>>, 0000001
> <<1:6>>, 000001
> <<1:5>>, 00001
> <<1:4>>, 0001
> <<16>>, 00010000
> <<1:3>>, 001
> <<2:4>>, 0010
> <<1:2>>, 01
> <<2:3>>, 010
> <<1:1>>, 1
> <<2:2>>, 10
> <<128>>, 10000000
> <<"ÿ">>] 11111111
Sorting is done bit-by-bit, with end-of-bitstring < 0 < 1.
Or am I just weird, thinking that that is intuitive?
David Mercer
More information about the erlang-questions
mailing list