+ # only perform ordering if manual group id is present
+ /\r .+$/bAUTOORDER;
+
+ b; # pass invalid records without processing
+
+ :AUTOORDER
+ # strip all fields but the name
+ s;^([^\t]+ [^\t]+ [^\t]+ [^\t]+ [^\t]+ )([^\r]+)\r (.+)$;\2;
+
+ # reduce to numerals
+ s;[^0-9]+;;g;
+
+ # append ordering field to dataset
+ H; g; s;\n;\t;;
+ b;