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

feature request: custom sort #40

Open
kobi2187 opened this issue Sep 7, 2018 · 2 comments
Open

feature request: custom sort #40

kobi2187 opened this issue Sep 7, 2018 · 2 comments

Comments

@kobi2187
Copy link

kobi2187 commented Sep 7, 2018

I have a text file with many lines looking like that
A = 3
B = 2
CGDSF = 4576

Can we have a value sort, somehow specifying the word or character to split the line by?
for example: select the = character, then run value-sort-lines

The result should be:
B = 2
A = 3
CGDSF = 4576

@Tyriar
Copy link
Owner

Tyriar commented Sep 10, 2018

Maybe the fix to this is to allow a custom sort to be defined by the user in a settings key as a JS string. Then that expression, say "a > b" can be eval'd by the extension? With good documentation, this would let users do things like what you ask:

"a.split('=')[1] > b.split('=')[1]"

Note there's no null checking or anything in the above. Thoughts?

@kobi2187
Copy link
Author

I solved it with regex.
replace: \s*([-\d\w]+) = ([\w\d-]+),?\n?
with: $2 = $1,\n

then, I select all (ctrl+a)
run natural sort
and replace again.

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

Successfully merging a pull request may close this issue.

2 participants