David Aldridge
asked on
Sorting two columns in a csv file
What is the best way to sort on two columns in a .csv file? Here is an example:
serverone, a1
serverone, cpu
serverone, a2
servertwo, cpu
servertwo, a2
servertwo, a1
etc....
What I would like to do is sort it like so:
serverone, a1
serverone, a2
serverone, cpu
servertwo, a1
servertwo, a2
servertwo, cpu
etc...
I got the first column using 'sort', but can't figure out the best way to sort the second.
Thanks!
David
serverone, a1
serverone, cpu
serverone, a2
servertwo, cpu
servertwo, a2
servertwo, a1
etc....
What I would like to do is sort it like so:
serverone, a1
serverone, a2
serverone, cpu
servertwo, a1
servertwo, a2
servertwo, cpu
etc...
I got the first column using 'sort', but can't figure out the best way to sort the second.
Thanks!
David
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ozo is absolutely correct. After doing some more research, I found out that I had some corrupted data in the csv file which was causing the problem. I apologize for wasting everyone's time. I think the fair thing is to split the points between the four responders.
Thanks everyone,
David
Thanks everyone,
David
Or, probably the more correct thing to do would be to perform your comparison on the first column, just like you're doing now, but in the event that they are equal, do a comparison on the second column as the tiebreaker.