Skip to content

Explicitly document sort stability #158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/Data/Array.purs
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,9 @@ modifyAtIndices is f xs =

-- | Sort the elements of an array in increasing order, creating a new array.
-- |
-- | The underlying sort may or may not be stable, depending on your JavaScript
-- | runtime.
-- |
-- | ```purescript
-- | sort [2, -3, 1] = [-3, 1, 2]
-- | ```
Expand All @@ -691,6 +694,9 @@ sort xs = sortBy compare xs
-- | Sort the elements of an array in increasing order, where elements are
-- | compared using the specified partial ordering, creating a new array.
-- |
-- | The underlying sort may or may not be stable, depending on your JavaScript
-- | runtime.
-- |
-- | ```purescript
-- | compareLength a b = compare (length a) (length b)
-- | sortBy compareLength [[1, 2, 3], [7, 9], [-2]] = [[-2],[7,9],[1,2,3]]
Expand All @@ -707,6 +713,9 @@ sortBy comp xs = sortImpl comp' xs
-- | Sort the elements of an array in increasing order, where elements are
-- | sorted based on a projection
-- |
-- | The underlying sort may or may not be stable, depending on your JavaScript
-- | runtime.
-- |
-- | ```purescript
-- | sortWith (_.age) [{name: "Alice", age: 42}, {name: "Bob", age: 21}]
-- | = [{name: "Bob", age: 21}, {name: "Alice", age: 42}]
Expand Down