I’ve just joined the forum and the past week (in my holidays) I’ve been watching Tutorials on Youtube trying to teach myself PowerShell.
I don’t understand much of it at all at the moment but I’m running into problems immediately. I have a list of Directories From -12 to +30.
-12
-11
And so on to
+29
+30
The closest I’ve got so far is
I’m trying to arrange these numerically but I understand that PowerShell 4.00 indexes using ASCII. There doesn’t seem to be a great deal out there on this; there are many articles but none of any real sustenance. I’ve tried various commands such as gci | Sort - Descending and Filter with different parameters etc.
Suprised there isn’t more quality info out there on this or a better solution to date. There was an interesting debating article saying that we’re failing to have not addressed this yet as humans are working to accomodate the computer’s needs here.
I tested it and I think it gives the result you are looking for. Basically, you are telling Sort-Object that if the name contains “+” to sort it Ascending order, but everything else sort descending.
Thanks Matt, that’s some tricky code there; don’t think I’ll ever get to that sort of level. That link looks pretty relevant; having a look through it now.
Late to the party, but came up with something similar to Olaf. I went with floating point and tested names without a number. They’ll sort as zero and use the original name as a tie breaker.