Skip to content

feat(#2313): sort_by -> sort.sorter, add sort.folders_first default true #2314

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

Merged
merged 2 commits into from
Jul 15, 2023

Conversation

alex-courtis
Copy link
Member

fixes #2313

rm -rf * ; mkdir -p a/10 a/20 z/10 z/20 ; touch a/5 a/15 a/25 z/15 b

sort_by = "name"
sort_folders_first = true

  ~/2313/..                   │
    a                       │~
      10                    │~
      20                    │~
       15                    │~
       25                    │~
       5                     │~
    z                       │~
      10                    │~
      20                    │~
       15                    │~
     b                       │~

sort_by = "name"
sort_folders_first = false

  ~/2313/..                   │
    a                       │~
      10                    │~
       15                    │~
      20                    │~
       25                    │~
       5                     │~
     b                       │~
    z                       │~
      10                    │~
       15                    │~
      20                    │~

rm -rf * ; mkdir -p a.z/10 a.z/20 z.a/10 z.a/20 ; touch a.z/5 a.z/15 a.z/25 z.a/15 b.a

sort_by = "extension"
sort_folders_first = true

  ~/2313/..                   │
    a.z                     │~
      10                    │~
      20                    │~
       15                    │~
       25                    │~
       5                     │~
    z.a                     │~
      10                    │~
      20                    │~
       15                    │~
     b.a                     │~

sort_by = "extension"
sort_folders_first = false

  ~/2313/..                   │
     b.a                     │~
    a.z                     │~
       15                    │~
       25                    │~
       5                     │~
      10                    │~
      20                    │~
    z.a                     │~
       15                    │~
      10                    │~
      20                    │~

rm -rf * ; mkdir -p a.a.z/10 a.a.z/20 z.a.a/10 z.a.a/20 ; touch a.a.z/5 a.a.z/15 a.a.z/25 z.a.a/15 b.a.a

sort_by = "suffix"
sort_folders_first = true

  ~/2313/..                   │
    a.a.z                   │~
      10                    │~
      20                    │~
       15                    │~
       25                    │~
       5                     │~
    z.a.a                   │~
      10                    │~
      20                    │~
       15                    │~
     b.a.a                   │~

sort_by = "suffix"
sort_folders_first = false

  ~/2313/..                   │
     b.a.a                   │~
    z.a.a                   │~
      10                    │~
       15                    │~
      20                    │~
    a.a.z                   │~
      10                    │~
       15                    │~
      20                    │~
       25                    │~
       5                     │~

rm -rf * ; mkdir -p a.a.z/10 a.a.z/20 z.a.a/10 z.a.a/20 ; touch a.a.z/5 a.a.z/15 a.a.z/25 z.a.a/15 b.a.a ; sleep 1; touch c.a.a ; sleep 1; touch d.a.a

sort_by = "modification_time"
sort_folders_first = true

  ~/2313/..                   │
    z.a.a                   │~
      10                    │~
      20                    │~
       15                    │~
    a.a.z                   │~
      10                    │~
      20                    │~
       15                    │~
       25                    │~
       5                     │~
     d.a.a                   │~
     c.a.a                   │~
     b.a.a                   │~

sort_by = "modification_time"
sort_folders_first = false

  ~/2313/..                   │
     d.a.a                   │~
    z.a.a                   │~
      10                    │~
       15                    │~
      20                    │~
     c.a.a                   │~
    a.a.z                   │~
      10                    │~
       15                    │~
      20                    │~
       25                    │~
       5                     │~
     b.a.a                   │~

rm -rf * ; mkdir -p a/10.zig a/20.toml z/10.a z/20 ; touch a/5 a/15.c a/25.txt z/15 b.toml c.c

sort_by = "filetype"
sort_folders_first = true

  ~/2313/..                   │
    a                       │~
      20.toml               │~
      10.zig                │~
       15.c                  │~
      󰈙 25.txt                │~
       5                     │~
    z                       │~
      10.a                  │~
      20                    │~
       15                    │~
     c.c                     │~
     b.toml                  │~

sort_by = "filetype"
sort_folders_first = false

  ~/2313/..                   │
     c.c                     │~
     b.toml                  │~
    a                       │~
       15.c                  │~
      20.toml               │~
      10.zig                │~
      󰈙 25.txt                │~
       5                     │~
    z                       │~
      10.a                  │~
       15                    │~
      20                    │~

@alex-courtis
Copy link
Member Author

@moniquelive you are now the SME on sorting, I'd be grateful for your review and test.

elseif not a.nodes and b.nodes then
return false
elseif a.nodes and b.nodes then
return C.name(a, b)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@moniquelive should we sort folders by suffix? Does that make any sense?

Copy link
Collaborator

@moniquelive moniquelive Jul 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not very usual, but sometimes you may have folders with suffixes to disambiguate their names such as .tmp, .old, .bkp, etc. But I believe people will want to turn this directory-grouping-by-suffix on or off. Should this be another setting? This is getting fractal pretty quickly... 👀

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have too many options... I'm happy for this to be opinionated.

Other sort methods apply the same rules to folders and files, this should too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried it, it looked odd, abandoned.

@alex-courtis alex-courtis changed the title feat(#2313): add sort_folders_first, default true feat(#2313): sort_by -> sort.sorter, add sort.folders_first, default true Jul 15, 2023
@alex-courtis alex-courtis changed the title feat(#2313): sort_by -> sort.sorter, add sort.folders_first, default true feat(#2313): sort_by -> sort.sorter, add sort.folders_first default true Jul 15, 2023
@alex-courtis alex-courtis merged commit ef305a8 into master Jul 15, 2023
@alex-courtis alex-courtis deleted the 2313-sort_folders_first branch July 15, 2023 05:20
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

Successfully merging this pull request may close these issues.

Don't sort directories first
2 participants