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

Collections not in alphabetical order #97

Open
dstillman opened this issue Dec 21, 2023 · 1 comment
Open

Collections not in alphabetical order #97

dstillman opened this issue Dec 21, 2023 · 1 comment

Comments

@dstillman
Copy link
Member

No description provided.

@dstillman dstillman added this to the 1.0 Public Beta milestone Dec 21, 2023
Dima-Android added a commit that referenced this issue Dec 24, 2023
Updating icon for "Remove from collection"
Upping versionCode to 34
@Dima-Android
Copy link
Collaborator

Dima-Android commented Dec 24, 2023

@dstillman
I’ve made collections sort correctly for most cases, except for the cases where the collection name contains numbers. Those collections are also sorted, but differently than on iOS.
Look at this side by side comparison:
iOS_1:
iOS_1
Android_1:
android_1
iOS_2:
iOS_2
Android_2:
android_2

On iOS this sorting logic is used:
return lCollection.name.compare(rCollection.name, options: [.numeric], locale: Locale.autoupdatingCurrent) == .orderedAscending

Basically iOS is using a built-in sdk function for this. Specifically this “.numeric” sort option, which treats numbers in a string in a special way.

We do not have something similar to this on Android, as a result numbers are getting treated the same way as other characters, hence the difference in the sorting result.
We would have to develop a custom sorting logic. All of the advice I can find on stackoverflow basically says that we will need to detect numbers in a string and treat them “as numbers” during sorting and not just as string characters.
But to do this we will either need to know the exact positionings of those numbers in string, so we could find them and convert them from chars to numbers.
Or patterns those numbers may follow in a string so we could use a regexp.

But the problem is that numbers in the collection name can appear in completely random positions. We could use some guesswork and maybe replace those numbers with special characters before sorting, and then play with it until we get the result similar to iOS, but this will take extra time.

Unless we can quickly figure out how iOS does it under the hood I suggest we keep current sorting and address it after release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants