.net - F# 中的 OrderBy ThenBy

标签 .net linq sorting f#

F# 中是否有任何类似于 LINQ fluent 语法的函数用于按多个表达式排序:

myList.OrderBy(fun x->x.Something).ThenBy(fun x->x.SomethingElse)

我喜欢这样的东西:
myList 
|> Seq.sort_by(fun x->x.Something) 
|> Seq.then_by(fun x->x.SomethingElse)

谢谢

最佳答案

使用元组作为排序键:

myList |> Seq.sortBy (fun x -> x.Something, x.SomethingElse)

关于.net - F# 中的 OrderBy ThenBy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/826317/

相关文章:

c# - 如何在 EF 中重用 where 子句

c# - Linq Left join, where, group by, count()

c# - 在 C# 中对对象的 ArrayList 进行排序

javascript - 根据值重新排序数组

c# - CLR 中方法表的精确布局(4.0 版)

c# - 比较数组 LINQ

c# - 内置异常处理的任务?

mongodb - meteor 中mongodb集合的自定义排序

.net - 当继承类使用默认构造函数实例化时,它是否也调用基类构造函数?

c# - 计算 CPU 使用率