-n Not Working in Assignment 1?

-n Not Working in Assignment 1?

par Alex Bell,
Nombre de réponses : 1

Interestingly, while completing the last step of the assignment I found that I kept getting "A_24_P99984" returned to me instead of "A_24_P945408". Using a less command I found this:

Improperly sorted data

As you can see, the data isn't sorting properly. This was using sort -k 1 -r -n (put in all sort of alignments), and after troubleshooting I added -t $'\t' as well, but nothing seems to change it. As you can see, it sorts by number: from left to right, and assuming null/nonexistent digits are higher, placing overall smaller numbers out of order.

If anyone has any idea on why -n seems to be giving this result, I'd appreciate the advice! Trying to look it up just got me advice to use -n, which... is not helpful.

En réponse à Alex Bell

Re: -n Not Working in Assignment 1?

par Alex Bell,
A friend worked it out! Since the data has letters it's treating it similar to a word. You have to isolate the numerical portion then sort it. Best of luck to anyone else with this issue!