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

Recognize indentation #39

Closed
ghost opened this issue Sep 4, 2018 · 5 comments
Closed

Recognize indentation #39

ghost opened this issue Sep 4, 2018 · 5 comments

Comments

@ghost
Copy link

ghost commented Sep 4, 2018

Is it possible to recognize indentation and keep indented lines attached to parents?

like from

ccc
bbb
    a fff
    a eee

to

bbb
    a eee
    a fff
ccc

instead of throwing e and f to beginning because of "a". First sorting as blocks, then sorting sub-lines in each block.

@Tyriar
Copy link
Owner

Tyriar commented Sep 10, 2018

@iinfin I don't understand the example, can you provide more details? Even ignoring whitespace the "to" example is in a strange order.

@ghost
Copy link
Author

ghost commented Sep 10, 2018

@Tyriar I didn't mean ignoring whitespace, lines starting with "a" have indentation so they're the child of "b", they stay under it. And get sorted in their own scope.

Thought would be useful for cases like markdown lists.

@Tyriar
Copy link
Owner

Tyriar commented Sep 11, 2018

Oh I get it, I think that's a little out of the scope of this extension unfortunately. Supporting every single possible way of sorting is unfeasible imo and makes the extension hard to use, that's what I'm trying to solve with the #40 issue. Perhaps there's a way to make sorts defined in settings somehow aware of other items? #40

@Tyriar Tyriar closed this as completed Sep 11, 2018
@lioneltrebuchon
Copy link

lioneltrebuchon commented Mar 14, 2019

Hello!

I understand this thread is closed, but I have a differing opinion from the boss (respect and greetings to you) @Tyriar .

Indeed, the use case of sorting multilevel/indented lists is to be found across the board... Many people look for it in Google Docs, MS Word, Sublime, Atom (there are questions about that on each one's forums, and stackoverflow)...

The fact that this feature is longed for also in non-coding environments shows that it is of use in many, language agnostic, cases. I will try to list a few:

  • creation of a visual dictionnary,
  • defining a multilevel list without yet defining the format (be it json, md, python dicts etc...),
  • one has several bloated classes in Python defining several variables, and wants to sort the variables for other developpers,
  • going through a document in a terminal with limited commands, such as head, tail and line-by-line reading...,
  • creation of a dependency list in a comment/header (of a function in ANY language) that should be read by code documentation generators such as Doxygen, Sphynx etc...

For most of those use cases, sorting would be an important step, and then one can always decorate, comment out etc... later. But keeping the indentation, and sorting according to it, would be great.

Conclusion:
Listing by indentation seems a common way of defining hiearchy. It is, to a certain extent, language agnostic.
Because it is visually useful to humans, and we are the ones coding after all.
Sorting with awareness of this way of defining hierarchy would be useful in many usecases.

@sparr
Copy link

sparr commented Sep 15, 2022

I am looking for this feature for sorting structured data like ini, json, yaml, etc files.

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