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

Deeper sorting of filenames #9

Open
PaPa31 opened this issue Mar 30, 2021 · 3 comments
Open

Deeper sorting of filenames #9

PaPa31 opened this issue Mar 30, 2021 · 3 comments

Comments

@PaPa31
Copy link

PaPa31 commented Mar 30, 2021

Hi !
Now your sorting works like this:
docusaurus-veiw-sorting

The algorithm is good for sorting by the first numbers in the filename.
But the second numbers (if any) are sorted without taking into account the value of the number.

Is it possible to sort filenames deeper?

auto-sidebar-sorting

Thanks!

@JaneJeon
Copy link

Something like https://www.npmjs.com/package/natsort would easily do the trick; you'd just need to replace the sorting algorithm with it in https://github.com/acrobit/docusaurus-plugin-auto-sidebars/blob/master/src/generator.ts#L20.

The bigger problem is that this repo seems to be dead, so if @PaPa31 you're interested in maintaining it, please fork it and make these simple changes! 👏

@JaneJeon
Copy link

Actually w/ docusaurus 2 beta it looks like the sidebars are already sorted!

@ghominejad
Copy link
Contributor

@JaneJeon @PaPa31 Sorry for delayed response and thanks for the suggestion.

You can change the following line and use natsort to fix this problem:

return files.sort(function(a, b) {

var sorter = natsort();

return files.sort(function(a, b) {
  var oa = getFileOrder(a);
  var ob = getFileOrder(b);
  return sorter(oa, ob);
});

Could you fix it and make a PR please?

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

3 participants