Hi,

You can use List.sortWith:

List.sortWith (fun x y -> compare y x) [1; 5; 4]

If you're using numbers, a trick is to sort them by their opposite number:

Seq.sortBy (~-) [1; 5; 4]

Laurent.

P.S.: why is there List.sortWith, but no Seq.sortWith? Is it an omission?

By on 6/24/2009 12:12 PM ()

thank you for your attention,

oh, but, my first article had an omission,

I'm linq-ing to SQL Server,

so I need some expression that can be used with like this,

query >@ this.PostThreadHeaders |> Seq.filter (fun r -> r.CategoryID = catetoryID) |> Seq.sort (fun r -> r.UDate) @>

By on 6/24/2009 12:39 PM ()

My understanding of LINQ is that if you use this kind of delegate, it would be carried out not at the SQL side but the C# side. You may need to use specific LINQ sort function for the LinqToSQL to translate.

Not sure how powerful is the F# LINQ bridge such that it can recognize the Seq.sort and transform that into the proper LINQ expression(function) which got transformed into the real SQL 'order by desc'

By on 6/24/2009 6:59 PM ()
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