Ordering files in tree view by *.*.* schema


#1

As far as I can tell there is no way of doing this in Atom, nor in any packages, but I’d like to be able to sort files alphabetically by filetype, etc.

In the Angular project I’m working on, I have things separated by filetype, but within the JS folder, I’ve got both my Angular modules and my Angular controllers as *.controller.js and *.module.js, which I quite like, but its difficult seeing which is which when the names stretch out of the tree view.

Basically, I’d like how it looks now on the left, to how it looks on the right:

BEFORE                  AFTER
|-bar.controller.js     |-bar.controller.js
|-foo.module.js         |-zzz.controller.js
\-zzz.controller.js     \-foo.module.js

Now it seems like a bit of an edge-case, but I feel this would also be good for separating by file type:

BEFORE             AFTER
|-about.html       |-foo-styles.css
|-index.html       |-styles.css
|-foo-script.js    |-other-styles.css
|-foo-styles.css   |-about.html
|-main-script.js   |-index.html
|-other-script.js  |-foo-script.js
|-other-styles.css |-main-script.js
\-styles.css       \-other-script.js

Sorting tree view by file type?
#2

One of the things I’m proposing as part of my behavior services idea is the addition of an atom.sort-files service that the tree-view package consumes. This will allow anyone to create a package that provides an atom.sort-files service that will sort the tree-view in whichever crazy way they want :wink: And the Atom team doesn’t have to provide a bazillion configuration options in the tree-view too!

Win win win all around :grinning:


#3

That sounds brilliant! Even if it was just some kind of regex string type thing in the config.cson or something, I’d be happy.

But this definitely seems like a good move going forward.


#4

If you want to try a PR out of it the array.sort is here

Then it’s a matter for you to optionally use a different sort comparator function.
Probably one that chunk into group rigth to left, then compare the inside of each group using normal order.

This could be presented in option as “Group file by file type” with added mention that you process multiple filename as a subkind of filetype.


The behavior service is a nice idea, but i’m not sure how it’s play as a GUI. And it looks like it need a lot of refactor. So the added checkmark is probably the best bet if you want it to happens in the near future.


Behavior Services