andrewplummer / Sugar

A Javascript library for working with native objects.
https://sugarjs.com/
MIT License
4.54k stars 305 forks source link

SortOrder issue #556

Closed Mottie closed 8 years ago

Mottie commented 8 years ago

It appears that a similar problem to #382 has popped up in Sugar v2.0.0.

I set up this demo using the default and Icelandic sort orders

Default

AÁÀÂÃĄBCĆČÇDĎÐEÉÈĚÊËĘFGĞHıIÍÌİÎÏJKLŁMNŃŇÑOÓÒÔPQRŘSŚŠŞTŤUÚÙŮÛÜVWXYÝZŹŻŽÞÆŒØÕÅÄÖ
sorts to
AÄÂÃÁÀĄBCÇĆČDĎÐEÈËÉÊĚĘFGĞHıIÍÎÏÌİJKLŁMNŃŇÑOÒÔÖÕÓPQRŘSŚŠŞTŤUÚÜÙÛŮVWXYÝZŹŻŽÞÆŒØÅ

Icelandic

AaÁáBbCcDdÐðEeÉéĘęFfGgHhIiÍíJjKkLlMmNnOoÓóPpQqRrSsTtUuÚúVvWwXxYyÝýZzÞþÆæÖö
sorts to
AaáÁBbcCDdÐðEeéÉĘęfFgGhHiIÍíjJkKLlMmNnOoÓóÖöPpQqRrsSTtuUÚúVvwWXxyYÝýZzÞþÆæ
Mottie commented 8 years ago

Nevermind! I wasn't setting the options using Sugar.Array.setOption.

Thanks for all your work!

Mottie commented 8 years ago

Ugh, sorry... actually it appears that using Sugar.Array.sortCollate ignores the options: see the updated demo

Default

Before:
AÁÀÂÃĄBCĆČÇDĎÐEÉÈĚÊËĘFGĞHıIÍÌİÎÏJKLŁMNŃŇÑOÓÒÔPQRŘSŚŠŞTŤUÚÙŮÛÜVWXYÝZŹŻŽÞÆŒØÕÅÄÖ

After:
ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞĄĆČĎĘĚĞİıŁŃŇŒŘŚŞŠŤŮŹŻŽ

Icelandic

Before:
AaÁáBbCcDdÐðEeÉéĘęFfGgHhIiÍíJjKkLlMmNnOoÓóPpQqRrSsTtUuÚúVvWwXxYyÝýZzÞþÆæÖö

After:
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÁÆÉÍÐÓÖÚÝÞáæéíðóöúýþĘę

Also sortCollate is only listed under setOptions, it doesn't show up when you try to search for it.

andrewplummer commented 8 years ago

It looks like you're using Sugar.Array.sortCollate, however that has also moved behind getOption, so this should instead be .sort(Sugar.Array.getOption('sortCollate')).

As for the docs, sorting options are listed here instead of in the main API method search.

Mottie commented 8 years ago

Thank you for clearing things up!

andrewplummer commented 8 years ago

No problem!