sortBy - Simple 2

Category:
LINQ
Description: This sample uses orderby to sort a list of words by length.
Code:
let LINQ20() =
let words = ["cherry"; "apple"; "blueberry"]

query {
for w in words do
sortBy (w.Length)
select w
} |> Seq.iter(fun n -> printfn "%s" n)

//sample output
// apple
// cherry
// blueberry


Execution Result:
apple
cherry
blueberry

Last edited Sep 14, 2011 at 1:48 AM by ttliu2000, version 1

Comments

No comments yet.