I have a pretty big array and one of the columns I wanted to sort by is composed of Letters and Numbers....ie
when I do a sort of that column, it doesn't sort them in the correct order
I am pretty sure it is a pretty simple solution, but after some searching I can't seem to find anything helpful
can you show a few lines of the array - is it actually an array or are you workign from a CSV file? Can you post an example of where the sorting breaks down?
It is both, I create an array from a csv.
Assuming the column you are interested in sorting is
How do you want it sorted?
The standard PowerShell sort produces this
PS> "33Cisco6", "22Cisco7", "35Cisco6" | sort22Cisco733Cisco635Cisco6
Normally we would sort starting with the leftmost characters which produces this order. What order do you need?
Sorry the table I posted isn't very clear the 33 and Cisco6 are two diferent columns...
Regardless, I would like it to sort the cisco6 column. The way i would like it to sort would just be the way one might normally expect.
So I would like all the Cisco6's to be together, followed by the Cisco7's then 8 etc...
If CiscoN where N is a number is one column then I would expect PowerShell to sort correctly e.g.
"Cisco6","Cisco7","Cisco6","Cisco6","Cisco8","Cisco6","Cisco8","Cisco6","Cisco7" | sort
What results are you getting?
One issue would be this
PS> "Cisco1","Cisco2","Cisco22","Cisco10" | sortCisco1Cisco10Cisco2Cisco22
if you just use single digits for numbers less than 10 you will get these odd looking results. It is a function of the way sorts work.
Of course now that I am trying this again, I am getting the results I want and I cannot duplicate the issue I was having before....Not sure what happened.
Thanks for your help