However, I want to sort these files with respect to their first digit.
First digit or first number? if digit, the 201.200.force.0.5.1LGY.pdb comes before 9.10.force.0.5.1LGY.pdb, since 2 (from 201) is lower than 9. If you want to sort by the first number, do a Schwartzian transform:
no warnings "numeric"; @sorted = map $_->[0], sort { $a->[1] <=> $b->[1] } map { [ $_, int $_ ] } @unsorted;
In reply to Re: sorting an array of file names
by shmem
in thread sorting an array of file names
by hotel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |