1

I have the following data,

% [START_TIME - END_TIME] TURN_NAME EMOTION [V, A, D]
[6.2901 - 8.2357]   Ses01F_impro01_F000 neu [2.5000, 2.5000, 2.5000]
[10.0100 - 11.3925] Ses01F_impro01_F001 neu [2.5000, 2.5000, 2.5000]
[14.8872 - 18.0175] Ses01F_impro01_F002 neu [2.5000, 2.5000, 2.5000]
[97.8900 - 102.9600]    Ses01F_impro01_F014 neu [2.5000, 3.5000, 3.5000]
[103.9700 - 106.7100]   Ses01F_impro01_F015 fru [2.0000, 3.5000, 3.0000]
[7.5712 - 10.4750]  Ses01F_impro01_M000 fru [2.5000, 2.0000, 2.5000]
[10.9266 - 14.6649] Ses01F_impro01_M001 fru [2.5000, 2.0000, 2.5000]
[16.8352 - 19.7175] Ses01F_impro01_M002 fru [2.0000, 3.5000, 3.5000]
[23.4700 - 28.0300] Ses01F_impro01_M003 fru [2.5000, 3.5000, 3.5000]
[101.8400 - 107.8700]   Ses01F_impro01_M013 ang [2.0000, 4.5000, 4.5000]

I am expecting the following result after sort command,

 % [START_TIME - END_TIME] TURN_NAME EMOTION [V, A, D]
[6.2901 - 8.2357]   Ses01F_impro01_F000 neu [2.5000, 2.5000, 2.5000]
[7.5712 - 10.4750]  Ses01F_impro01_M000 fru [2.5000, 2.0000, 2.5000]
[10.0100 - 11.3925] Ses01F_impro01_F001 neu [2.5000, 2.5000, 2.5000]
[10.9266 - 14.6649] Ses01F_impro01_M001 fru [2.5000, 2.0000, 2.5000]
[14.8872 - 18.0175] Ses01F_impro01_F002 neu [2.5000, 2.5000, 2.5000]
[16.8352 - 19.7175] Ses01F_impro01_M002 fru [2.0000, 3.5000, 3.5000]
[23.4700 - 28.0300] Ses01F_impro01_M003 fru [2.5000, 3.5000, 3.5000]
[97.8900 - 102.9600]    Ses01F_impro01_F014 neu [2.5000, 3.5000, 3.5000]
[101.8400 - 107.8700]   Ses01F_impro01_M013 ang [2.0000, 4.5000, 4.5000]
[103.9700 - 106.7100]   Ses01F_impro01_F015 fru [2.0000, 3.5000, 3.0000]

I used the following sort command to order from the second character,

 sort -k1.2 filename 

But it gives the first line of [10.0100....]. So, the sort command will order based on the most left decimal number (START_TIME) while kept the header on the top. Any experienced sort user here can help...?

1 Answer 1

1

You need to specify you want numeric sorting with the -g option:

{ read -r header; echo "$header"; sort -g -k 1.2,1; } < filename
Sign up to request clarification or add additional context in comments.

1 Comment

Works perfectly as expected. Thank you for the lesson!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.