kutyel / linq.ts

🌀LINQ for TypeScript

Home Page:http://kutyel.github.io/linq.ts/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OrderBy sorts in ASCII style

mstrzoda opened this issue · comments

OrderBy sorts first big letters, then small and then special characters like language specific letters. List like this: "Ägypten", "Griechenland", "Deutschland" will be sorted in that way:
"Deutschland", "Griechenland", "Ägypten". "Ägypten" should be first in that example.

Is this an issue? I mean, JavaScript can only order strings according to ASCII positions, if not you would have to provide your custom sorting according to your specific needs/language, how would you improve this? 😄

i think we could use at some point this function:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare,

or we should allow devs to inject his own comparer like in original OrderBy:
https://msdn.microsoft.com/pl-pl/library/bb549422(v=vs.110).aspx

Great feedback! I think the most flexible solution is to implement the optional comparer parameter, and it is also an easy fix! 😉 Feel free to land a PR if you feel like it, if not I will fix it this week!

If you have some free time please do that, i have huuuuuuuge task to do by the end of the month (i don't know if i will have time for sleep :/)

🎉 This issue has been resolved in version 1.11.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

great, big thx!

Hope you like the new test 😜

linq.ts/test/list.ts

Lines 479 to 484 in e641364

t.deepEqual(
new List<string>(['Deutschland', 'Griechenland', 'Ägypten'])
.OrderBy(x => x, (a, b) => a.localeCompare(b))
.ToArray(),
['Ägypten', 'Deutschland', 'Griechenland']
)

schööööön!