Skip to content

Instantly share code, notes, and snippets.

@PatrickMcDonald
Created September 10, 2014 20:37
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 PatrickMcDonald/1d7be5d68aefcc45fc57 to your computer and use it in GitHub Desktop.
Save PatrickMcDonald/1d7be5d68aefcc45fc57 to your computer and use it in GitHub Desktop.
[<CompiledName("SortByDescending")>]
let sortByDescending f xs =
match xs with
| [] | [_] -> xs
| _ ->
let compareByDescending x y = compare (f y) (f x)
sortWith compareByDescending xs
[<CompiledName("SortDescending")>]
let sortDescending xs =
match xs with
| [] | [_] -> xs
| _ ->
let compareDescending x y = compare y x
sortWith compareDescending xs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment