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

Multilevel support #94

Open
lavermil opened this issue May 27, 2021 · 2 comments
Open

Multilevel support #94

lavermil opened this issue May 27, 2021 · 2 comments

Comments

@lavermil
Copy link

lavermil commented May 27, 2021

Can you add the support to do single and multilevel block sorts. So you will sort based on the parent (non-indented lines) but also have an option to sort the children and any other sub-levels too.

This is very helpful in the world of comparing network device, application configs, etc using diff tools. Sometime as different version come out and they change config files/etc around the order of stuff/etc. Without this python script I have below it is very hard to compare them.

My method in python I am using allows me to specify what the indent pattern is. For example if you want to use a tab, 2 space, 3 space, 4 spaces, etc. I have also added in python the ability to filter out lines like ! or # or what ever I want as long as it is an exact match.

Example:

Parent3
!
Parent2
  child1
    child1c
    child1a
    child1b
!
Parent1
  child2
    child2b
      child1a
      child1c
      child1b
    child2a
      child1b
      child1a
      child1c
  child1

Desired:

Parent1
  child1
  child2
    child2a
      child1a
      child1b
      child1c
    child2b
      child1a
      child1b
      child1c
Parent2
  child1
    child1a
    child1b
    child1c
Parent3
@lavermil
Copy link
Author

lavermil commented Jun 9, 2021

Here is a sample config to play with too.
sample_config.txt

@leowill01
Copy link

+1 this would also be super useful for sorting markdown task lists where it could sort checked - [x] below unchecked - [ ] items while keeping tasks at the same indentation levels by ignoring whitespace preceding the task list syntax, e.g. regex = ^[:blank:]*.+.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants