A workaround I’ve used to get stable sorting in Javascript is to add an 
artificial index, sort with that as a secondary sort parameter, and then 
strip that index off from the result.

To sort a list of int-pairs in Elm it could go like this:

stableSort : List (Int, Int) -> List (Int, Int)
stableSort ps =
  ps
  |> List.indexedMap (,)
  |> List.sortBy (\(i, (a, _)) -> (a, i))
  |> List.map snd

On Wednesday, July 13, 2016 at 10:10:57 AM UTC-5, Mark Green wrote:

It appears that the functionality of List.sortBy is semi-browser dependent 
> when the sorting function is a partial ordering.
>
​

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to