Skip to content

Instantly share code, notes, and snippets.

@cmcbride
Created May 4, 2011 16:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmcbride/955519 to your computer and use it in GitHub Desktop.
Save cmcbride/955519 to your computer and use it in GitHub Desktop.
(* for use with Array. Easy way to create an index, and then sort the index *)
let index a = Array.init ( Array.length a) (fun i -> i)
let sort_index a idx =
let cmpi i j = compare a.(i) a.(j) in
Array.fast_sort cmpi idx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment