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

Sort by ascending values #9

Open
jlnrrg opened this issue Mar 14, 2023 · 3 comments
Open

Sort by ascending values #9

jlnrrg opened this issue Mar 14, 2023 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@jlnrrg
Copy link

jlnrrg commented Mar 14, 2023

I noticed that the default output is sorted descending.
It has been a long time since I last worked with PS, so I am not aware how to resort the tree later on.
If you know I would be happy for advice, otherwise I would propose a sorting flag, or to make the default sort ascending, as that would mimik the default windows explorer sorting behaviour.

Cmd I've run: Get-PSTree -Directory

@santisq
Copy link
Owner

santisq commented Mar 14, 2023

Hi @jlnrrg thanks for opening this issue, I'm aware of it but I'm not sure if there is a way around it. This is a consequence of using a Stack<T> instead of doing it with recursion. Older versions of this function were using recursion but it was changed for efficiency. If you find out a way please let me know and I'll try to implement it.

@santisq santisq self-assigned this Mar 14, 2023
@santisq santisq added the help wanted Extra attention is needed label Mar 14, 2023
@santisq santisq removed their assignment Apr 1, 2023
@krzydoug
Copy link

Now that you've rewritten in C#, shouldn't it be easy to sort it ascending by default now? I'm guessing here but wondered if you thought about it. The link to the stack code is broken now by the way.

@santisq
Copy link
Owner

santisq commented Apr 18, 2024

Now that you've rewritten in C#, shouldn't it be easy to sort it ascending by default now? I'm guessing here but wondered if you thought about it. The link to the stack code is broken now by the way.

Hi @krzydoug, it's not as easy as it may seem, each sub tree needs to be sorted individually (all files within a folder) and then each parent tree (all folders). I don't see a way to make it happen easily and also, even then, making it work would have a high performance hit but if you want to give it a go, the method that traverses the folders is here: https://github.com/santisq/PSTree/blob/main/src/PSTree/Commands/GetPSTreeCommand.cs#L143-L249

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants