alexandru-dinu / obsidian-sortable

Table sorting plugin for https://obsidian.md
MIT License
233 stars 8 forks source link

Incorrect MAC addresses sorting #35

Open revolter opened 1 year ago

revolter commented 1 year ago

For these entries:

02-E5-27-38-DB-CF
00-55-DA-52-FA-15
1C-69-7A-6B-15-9D

this extension sorts them as:

00-55-DA-52-FA-15
1C-69-7A-6B-15-9D
02-E5-27-38-DB-CF

instead of:

00-55-DA-52-FA-15
02-E5-27-38-DB-CF
1C-69-7A-6B-15-9D
Diff ```diff 00-55-DA-52-FA-15 -1C-69-7A-6B-15-9D 02-E5-27-38-DB-CF +1C-69-7A-6B-15-9D ```
alexandru-dinu commented 1 year ago

Hello,

Apologies for the inconvenience. As mentioned in the README, Sortable currently supports numbers, strings, ISO dates.

I am rethinking the support for multiple data types, but in the meantime, if you are willing to contribute a fix, feel free to do so!

revolter commented 1 year ago

As mentioned in the README, Sortable currently supports numbers, strings, ISO dates.

Yes, I got that. But what I don't understand is that even sorting them as simple strings should work. You can verify it using a tool like https://texttools.org/sort-text.


Actually, isn't it because you're enabling numeric here:

https://github.com/alexandru-dinu/obsidian-sortable/blob/cbdfea4f71d9358c2dad52954d2904543434a263/src/sortable.ts#L112

?

alexandru-dinu commented 1 year ago

Yes, it's due to the collator used for the natural sorting which interprets 02 > 1C.

Errors like this will continue to pop up, but I don't want to bodge things anymore, rather rethink the method from the ground up. I like the Wikipedia approach of specifying a data-sort-type attribute or just letting the user write a custom comparator function for the column they want to sort (#12).

In the meantime, feel free to patch the source to suit your needs.