#!/usr/bin/awk -f

BEGIN {
    gl_vDirNumsLen = 1;
}

{
    vDNamLen = split($0, vDNam, "_");
    vDirNums[gl_vDirNumsLen] = vDNam[1];
    vDirNames[gl_vDirNumsLen] = $0;
    gl_vDirNumsLen++;
}

END {
    asort(vDirNums);
    for (i=gl_vDirNumsLen-1; i>0; i--) {
        vRegEx = sprintf("%i_", vDirNums[i]);
        for (j=1; j<=gl_vDirNumsLen; j++) {  
#            printf("%s; %s\n", vDirNames[j], vRegEx);
            if (match(vDirNames[j], vRegEx)) {
                print vDirNames[j];
                break;
            }
        }
    }
}
