You're right. I was assuming that the problem was that we get different
behaviors in different browsers.

If your goal is to have identical results on all platforms, use sortWith
and specify a comparison function that never returns EQ.

But if your goal is to preserve the original order when elements are
identical, you can't do that with the standard library.

On Wed, Jul 13, 2016 at 8:40 AM, Janis Voigtländer <
[email protected]> wrote:

> Isn’t List.sortWith using exactly the same unstable JS sorting function
> under the hood?
> ​
>
> 2016-07-13 17:22 GMT+02:00 Nick H <[email protected]>:
>
>> For a workaround, all you need to do is use List.sortWith instead.
>>
>> sortBy uses JavaScript's native array sorting function under the hood.
>> The JS function is documented as being unstable
>> <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort>
>> (order not preserved when two elements are equal). Sounds like it might be
>> good to add a documentation note.
>>
>> On Wed, Jul 13, 2016 at 8:10 AM, Mark Green <[email protected]> wrote:
>>
>>> It appears that the functionality of List.sortBy is semi-browser
>>> dependent when the sorting function is a partial ordering.
>>>
>>> My current version of Firefox sorts according to the partial order, and
>>> within ties, maintains the order from the original list. However, user
>>> reports have been that some other browsers sort according to the partial
>>> order and apply arbitrary order within ties, which is obviously problematic.
>>>
>>> Is there a way around this and could a work-around be added to the
>>> library?
>>>
>>> Mark
>>>
>>> --
>>> 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.
>>>
>>
>> --
>> 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.
>>
>
> --
> 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.
>

-- 
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