Hello.

In F# sources List.sort_by is defined as wrapper other sort:

1
let sort_by f l = sort (fun x y -> compare (f x) (f y)) l

so, you can use simple Perl's idea translation:

1
2
3
List.map (fun el -> (el.Func(),el)) your_list 
  |> List.sort (fun (h1,v1) (h2,v2) -> compare h1 h2)
  |> List.map (fun (_,el) -> el)
By on 2/1/2009 3:07 AM ()

Very clear answer thanks!

It never occurred to me that I could actually peruse F# library source code to see the definition of List.sort_by (it actually does what I thought it might.. i.e. 'not enough' by itself).

By on 2/1/2009 5:39 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper