perl - How to sort a file list according their part of the file name? -


i have array(@pssm_list) contains files this

1.nr.pssm 2.nr.pssm 3.nr.pssm 4.nr.pssm 5.nr.pssm 6.nr.pssm 7.nr.pssm 

the name of file list 1.nr.pssm 226.nr.pssm

i try use sort(@pssm_list) , order not 1 226

so try write code this

opendir(pssm_handle,$argv[0]); @pssm_list = grep(/\.pssm/,readdir(pssm_handle));  $tag = 0; until($tag > 226) {         foreach $file (@pssm_list)         {                 @temp = split("[.]",$file);                 if($temp[0] == $tag)                 {                         push(@sorted,join("",$file));                 }         }         $tag++; } 

i want know there exists solution can sort list in 1 line?

i hit upon problem well, , used package called sort::naturally me sort numbers correctly.

under natural sorting, numeric substrings compared numerically, , other word-characters compared lexically.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -