Video-hub-app: Sort files with numbers in increasing order, not lexicographically

Created on 1 Jul 2020  路  11Comments  路  Source: whyboris/Video-Hub-App

Currently files are sorted:

1, 10, 11, 12 ... 2, 20, 21, 22 ... 3, 30, 31 ...

rather than

1, 2, 3 ... 10, 11, 12 ... 20, 21, 22 ...

Might not be annoying to fix, but leaving the issue open in case someone wants a challenge 馃し

good first issue

Most helpful comment

@HerrRobo thanks! i'll try to see if i can get to it also.
I went through your branch, it seems ok,
you just meant that you want to test it with more test files and naming? to see if it really fixed it?

All 11 comments

Got you sorted: https://www.npmjs.com/package/natural-orderby

Geddit? 馃槄

paths = ['01 first', '10 fourth', '1 second', '2 third']
console.log('before: ' + paths)
console.log('after:  ' + window.naturalOrderBy.orderBy(paths))
"before: 01 first,10 fourth,1 second,2 third"
"after:  01 first,1 second,2 third,10 fourth"

https://jsfiddle.net/8xgtwL05/

I love it!

ps - what's "Geddit"? 馃槄 is it phonetic "get it"?

Hello, is this issue still open?
If so, I'd like to help out - first timer here!

Hello @HerrRobo -- thank you for your interest 馃榿

Please feel free to give this a try and reach out if you ever have trouble or questions.

Are you also thinking of using the natural-orderby package to simplify the task?

Cheers 馃

Sounds great, thanks!
Yep, my current approach is to look at natural-orderby that cal2195 suggested, which I believe would be used primarily in the sorting pipe class.

If this ends up being the approach accepted, the natural-orderby package would be a new dependency added to the project as well - obvious, but just a heads up anyway 馃榿

hey, let me know if you need help here, I can try and take it

@HerrRobo -- would you prefer to keep working on it or are you OK with @orkomlosh taking it? I glanced at your fork of VHA and don't yet see a branch for this issue 馃 please let us know 馃憤

@whyboris Hello, sorry for the delay here. My fork has been updated and now contains a new branch which includes the natural-orderBy dependency. The results from sorting numbers naturally Alphabetically ascending/descending appears to work as intended, but I am unsure if the rest of my sorted test files are being sorted correctly from this approach. I need a deeper understanding into natural ordering, so I won't be making a PR from this if it happens to not be enough.

Unfortunately I am unable to investigate much further because of personal time constraints, so feel free to take over @orkomlosh ! By all means, use the contents of my branch if it helps with a working solution! Best of luck!

@HerrRobo thanks! i'll try to see if i can get to it also.
I went through your branch, it seems ok,
you just meant that you want to test it with more test files and naming? to see if it really fixed it?

Thanks @HerrRobo for the update and your work 馃檱
Looking at it: https://github.com/whyboris/Video-Hub-App/compare/main...HerrRobo:sort-files-with-numbers
It seems like all that would be needed 馃

Thank you @HerrRobo for the work -- I suspect we're 99% of the way there with your code, so I created a PR with it -- I hope you do not mind 馃檱 #540

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cal2195 picture cal2195  路  6Comments

whyboris picture whyboris  路  5Comments

cal2195 picture cal2195  路  6Comments

whyboris picture whyboris  路  3Comments

whyboris picture whyboris  路  5Comments