Skip to main content
added 149 characters in body
Source Link
Kusalananda
  • 356.1k
  • 42
  • 737
  • 1.1k

As @terdon noticed, the inclusion of X and Y and the fact that the numbers run from 1 to 22 identifies this as a possible list of human chromosomes (which is why he sayshe says that chromosome M (mitochondrial) may be missing).

To sort a list of numbers, one would usually use sort -n:

$ sort -n -o list.sorted list 

where list is the unsorted list, and list.sorted will be the resulting sorted list.

With -n, sort will perform a numerical sort on its input. However, since some of the input is not numerical, the result is probably not the intended; X and Y will appear first in the sorted list, not last (the sex chromosomes are usually listed after chromosome 22).

However, if you use sort -V (for "version sorting"), you will actually get what you want:

$ sort -V -o list.sorted list $ cat list.sorted 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 X Y 

This will probably still not work if you do add M as that would be sorted before X and not at the end (which I believe is how it's usually presented).

As @terdon noticed, the inclusion of X and Y and the fact that the numbers run from 1 to 22 identifies this as a possible list of human chromosomes (which is why he says that chromosome M (mitochondrial) may be missing).

To sort a list of numbers, one would usually use sort -n:

$ sort -n -o list.sorted list 

where list is the unsorted list, and list.sorted will be the resulting sorted list.

With -n, sort will perform a numerical sort on its input. However, since some of the input is not numerical, the result is probably not the intended; X and Y will appear first in the sorted list, not last (the sex chromosomes are usually listed after chromosome 22).

However, if you use sort -V (for "version sorting"), you will actually get what you want:

$ sort -V -o list.sorted list $ cat list.sorted 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 X Y 

This will probably still not work if you do add M as that would be sorted before X and not at the end (which I believe is how it's usually presented).

As @terdon noticed, the inclusion of X and Y and the fact that the numbers run from 1 to 22 identifies this as a possible list of human chromosomes (which is why he says that chromosome M (mitochondrial) may be missing).

To sort a list of numbers, one would usually use sort -n:

$ sort -n -o list.sorted list 

where list is the unsorted list, and list.sorted will be the resulting sorted list.

With -n, sort will perform a numerical sort on its input. However, since some of the input is not numerical, the result is probably not the intended; X and Y will appear first in the sorted list, not last (the sex chromosomes are usually listed after chromosome 22).

However, if you use sort -V (for "version sorting"), you will actually get what you want:

$ sort -V -o list.sorted list $ cat list.sorted 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 X Y 

This will probably still not work if you do add M as that would be sorted before X and not at the end (which I believe is how it's usually presented).

added 1 character in body
Source Link
terdon
  • 252.7k
  • 69
  • 481
  • 719

As @terdon noticed, the inclusion of X and Y and the fact that the numbers run from 1 to 22 identifies this as a possible list of human chromosomes (which is why he says that chromosome M (mitochondriamitochondrial) may be missing).

To sort a list of numbers, one would usually use sort -n:

$ sort -n -o list.sorted list 

where list is the unsorted list, and list.sorted will be the resulting sorted list.

With -n, sort will perform a numerical sort on its input. However, since some of the input is not numerical, the result is probably not the intended; X and Y will appear first in the sorted list, not last (the sex chromosomes are usually listed after chromosome 22).

However, if you use sort -V (for "version sorting"), you will actually get what you want:

$ sort -V -o list.sorted list $ cat list.sorted 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 X Y 

This will probably still not work if you do add M as that would be sorted before X and not at the end (which I believe is how it's usually presented).

As @terdon noticed, the inclusion of X and Y and the fact that the numbers run from 1 to 22 identifies this as a possible list of human chromosomes (which is why he says that chromosome M (mitochondria) may be missing).

To sort a list of numbers, one would usually use sort -n:

$ sort -n -o list.sorted list 

where list is the unsorted list, and list.sorted will be the resulting sorted list.

With -n, sort will perform a numerical sort on its input. However, since some of the input is not numerical, the result is probably not the intended; X and Y will appear first in the sorted list, not last (the sex chromosomes are usually listed after chromosome 22).

However, if you use sort -V (for "version sorting"), you will actually get what you want:

$ sort -V -o list.sorted list $ cat list.sorted 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 X Y 

This will probably still not work if you do add M as that would be sorted before X and not at the end (which I believe is how it's usually presented).

As @terdon noticed, the inclusion of X and Y and the fact that the numbers run from 1 to 22 identifies this as a possible list of human chromosomes (which is why he says that chromosome M (mitochondrial) may be missing).

To sort a list of numbers, one would usually use sort -n:

$ sort -n -o list.sorted list 

where list is the unsorted list, and list.sorted will be the resulting sorted list.

With -n, sort will perform a numerical sort on its input. However, since some of the input is not numerical, the result is probably not the intended; X and Y will appear first in the sorted list, not last (the sex chromosomes are usually listed after chromosome 22).

However, if you use sort -V (for "version sorting"), you will actually get what you want:

$ sort -V -o list.sorted list $ cat list.sorted 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 X Y 

This will probably still not work if you do add M as that would be sorted before X and not at the end (which I believe is how it's usually presented).

Source Link
Kusalananda
  • 356.1k
  • 42
  • 737
  • 1.1k

As @terdon noticed, the inclusion of X and Y and the fact that the numbers run from 1 to 22 identifies this as a possible list of human chromosomes (which is why he says that chromosome M (mitochondria) may be missing).

To sort a list of numbers, one would usually use sort -n:

$ sort -n -o list.sorted list 

where list is the unsorted list, and list.sorted will be the resulting sorted list.

With -n, sort will perform a numerical sort on its input. However, since some of the input is not numerical, the result is probably not the intended; X and Y will appear first in the sorted list, not last (the sex chromosomes are usually listed after chromosome 22).

However, if you use sort -V (for "version sorting"), you will actually get what you want:

$ sort -V -o list.sorted list $ cat list.sorted 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 X Y 

This will probably still not work if you do add M as that would be sorted before X and not at the end (which I believe is how it's usually presented).