How to sort these data...

0 views
Skip to first unread message

Michael Jaaka

unread,
Nov 7, 2009, 4:38:57 PM11/7/09
to Clojure
Hello I have such data

[ [ "tom" 23 ] [ "ann" 4434 ] [ "tom" 1234 ] ["mike" 34 ] ]

I would like to sort these data so finally i got

[ [ "ann" 4434 ] ["mike" 34 ] [ "tom" 23 ] [ "tom" 1234 ] ]

note that i don't care the order between "tom" keys (1234 can be
before 23)

I have seen sort-by but I can't find tutorial how to use keyfn

Michael Jaaka

unread,
Nov 8, 2009, 7:17:43 AM11/8/09
to Clojure
OK. I have figured it out. I just looked into core.clj and noticed that keyfn is a function which know how to get a value from an element in a collection. That value is just compared with other.

2009/11/7 Michael Jaaka <michae...@googlemail.com>
Reply all
Reply to author
Forward
0 new messages