RosettaCodeData/Task/Sort-an-array-of-composite-structures/F-Sharp/sort-an-array-of-composite-structures-2.fs
2023-07-01 13:44:08 -04:00

4 lines
202 B
FSharp

type Person = { name:string; id:int }
let persons2 = [{name="Joe"; id=120}; {name="foo"; id=31}; {name="bar"; id=51}]
let sorted = List.sortBy (fun p -> p.id) persons2
for p in sorted do printfn "%A" p