Skip to content
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

possible case insensitive sort issue.. #31

Closed
jeske opened this issue Feb 17, 2013 · 1 comment
Closed

possible case insensitive sort issue.. #31

jeske opened this issue Feb 17, 2013 · 1 comment

Comments

@jeske
Copy link

jeske commented Feb 17, 2013

Just reading the code, I wonder if you mean this code in isense.ts...

// Case insensitive sorting
function caseInsensitiveSort(a: { name: string; }, b: { name: string; }) {
if (a.name.toLowerCase() < b.name.toLowerCase()) return -1;
if (a.name.toLowerCase() > b.name.toLowerCase()) return 1;
return 0;
}

To be more like this..

// Case insensitive sorting
function caseInsensitiveSort(a: { name: string; }, b: { name: string; }) {
if (a.name.toLowerCase() < b.name.toLowerCase()) return -1;
if (a.name.toLowerCase() > b.name.toLowerCase()) return 1;
// the lower-case strings are equal, so now put them in local order..
if (a.name < b.name) return -1;
if (a.name > b.name) return 1;
return 0;
}

This code will cause strings which different only in case to be adjacent to eachother, but in a deterministic way without collisions.

@jbaron
Copy link
Owner

jbaron commented Feb 17, 2013

Thanks for reporting the issue (to be honest, I didn't even think about that scenario). I added your fix in the latest code that I just checked in.

@jbaron jbaron closed this as completed Feb 17, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants