The Book of F#: Breaking Free with Managed Functional Programming by Dave Fancher

The Book of F#: Breaking Free with Managed Functional Programming by Dave Fancher

Author:Dave Fancher
Language: eng
Format: epub, mobi, pdf
Tags: COMPUTERS / Programming / Microsoft
ISBN: 9781593275822
Publisher: No Starch Press
Published: 2014-03-13T16:00:00+00:00


let movies = [| ("The Terminator", "1984") ("Predator", "1987") ("Commando", "1985") ("Total Recall", "1990") ("Conan the Destroyer", "1984") |]

The easiest way to sort by year is to just project the year value via sortInPlaceBy like this:

> movies |> Array.sortInPlaceBy (fun (_, y) -> y) movies;; val it : (string * string) [] = [|("The Terminator", "1984"); ("Conan the Destroyer", "1984"); ("Commando", "1985"); ("Predator", "1987"); ("Total Recall", "1990")|]

Alternatively, we can directly compare two elements with sortInPlaceWith:



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.