Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] sort/compare

From: antonr:iinet:au at: 8-Dec-2003 2:32

Just wondering if there is a way to find the indices of the pair of values passed to the compare function (directly, without using find). Here's a simple use of sort/compare: sort/compare a: [1 4 9 7 3 2] func [v1 v2][v2 < v1] Now here you can see how many comparisons occurred and at what positions they were at (hopefully): n: 0 sort/compare a: [1 4 9 7 3 2] func [v1 v2][ print [index? find a v1 index? find a v2 ":" v1 v2] n: n + 1 v1 < v2 ] ?? n (At the end, n = 16). (Should be able to figure what type of sort is used..) But, consider that my values might not be unique, so using index? find ... is unreliable. Anton.