[REBOL] Sort in REBOL
From: carl:s:rebol at: 7-Sep-2002 13:45
Noticed the thread on SORT, but I don't have time to read it all.
A few notes:
1) SORT in recent versions of REBOL is much more reliable. It is
also quite fast, but that depends on what you're sorting and the
function you use for comparison. We use it all the time.
2) If you want a stable sort, return 1, -1, and 0 from a
sort subfunction, rather than true and false.
sort/compare data func [a b] [
if a < b [return 1]
if a > b [return -1]
0
]
3) The /ALL refinement allows you to sort more complex data,
for example, by data fields within blocks:
data: [ ["name" 123] ["fred" 345] ]
sort/compare/all data func [a b] [a/2 < b/2]
Perhaps you already know all this... but, I figured, what the
heck...
-Carl