keysort + removing duplicate keys
Ulf Wiger (AL/EAB)
ulf.wiger@REDACTED
Wed Mar 1 10:37:18 CET 2006
At least I found this slightly surprising:
2> lists:ukeysort(1,[{1,a},{1,b}]).
[{1,a},{1,b}]
3> lists:ukeysort(1,[{1,a},{1,a}]).
[{1,a}]
The man page says that lists:ukeysort/2 removes
consecutive duplicates. I just assumed that it meant
_duplicate keys_, but apparently not. Perhaps the
manual could emphasize this point, for the sake of
dunces like me?
I went on to orddict:
4>
orddict:from_list([{'$5',7},{'$4',6},{'$3',5},{'$2',4},{'$2',3},{'$1',2}
,{'$1',1}]).
[{'$1',1},{'$2',3},{'$3',5},{'$4',6},{'$5',7}]
(That is, I have a list with proplist semantics, and want to produce a
list of values sorted by the lexical order of the keys.)
orddict:from_list(L) seems to do what I want, but the man page doesn't
mention how orddict goes about treating consecutive duplicates. Wouldn't
this sort information be useful?
/Ulf W
More information about the erlang-questions
mailing list