Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

Custom sort on a column

$
0
0
Hello all,

How do I achieve this? I have A, B and A/B in different variables in a file in col2.
I want them to sort in such a way, that the variables appear together, and within a variable, the data is sorted in the order A,B and then A/B. If I sort on the second column, the order becomes A, A/B, B but I want A,B,A/B.

IN
Code:

Variable1 A/B 1
Variable2 A    2
Variable3 B    3
Varibale2 B    4
Variable2 A/B 5
Variable2 A/B 6
Varibale1 A/B 7
Variable1 B    8
Variable1 A    9
Variable3 A    10
Variable3 A/B 11

OUT
Code:

Variable1 A    9
Variable1 B    8
Variable1 A/B 1
Varibale1 A/B 7
Variable2 A    2
Varibale2 B    4
Variable2 A/B 5
Variable2 A/B 6
Variable3 A    10
Variable3 B    3
Variable3 A/B 11


Viewing all articles
Browse latest Browse all 16232

Trending Articles