[erlang-questions] sorting rules regarding bit strings
Thu Apr 2 16:36:29 CEST 2009
David Mercer wrote:
> 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:
Sure, and it's also consistent with how larger "words"
> Sorting is done bit-by-bit, with end-of-bitstring < 0 < 1.
> Or am I just weird, thinking that that is intuitive?
I guess the main problem is that the way bitstrings
are pretty-printed gives the wrong visual cues,
as regards sorting.
<<1:1>> reads as the number one, and not necessarily
as "the most significant bit", whereas larger words,
as above give visual cues that explain the ordering
(just think of each element as a byte, and is sorts
just like a string.)
CTO, Erlang Training & Consulting Ltd
More information about the erlang-questions