I am trying to sort set of string elements in descending order but the result surprises me. I can see 7.1.1 comes before 7.10.1, not sure why.
$ cat sort.sh
#!/bin/bash
for i in $( echo "5.2.0 5.1.2 7.1.1 7.10.1" | tr ' ' '\n' | sort -r )
do
echo $i
done
Output:
$ ./sort.sh
7.1.1
7.10.1
5.2.0
5.1.2
Expected output:
$ ./sort.sh
7.10.1
7.1.1
5.2.0
5.1.2
Am i missing anything here? Any tips would be really helpful.
Thanks
sort -rn