Javascript - 对包含字母,数字和日期的字符串数组进行排序

时间:2013-09-25 18:27:22

标签: javascript arrays sorting

  var array=['sss_aaa_2013-09-25_part1.txt',
 'sss_aaa_2013-09-25_part2.txt',
 'sss_aaa_2013-09-25_part3.txt',
 'sss_aaa_2013-09-25_part12.txt',
 'sss_aaa_2013-09-25_part4.txt',
 'sss_aaa_2013-09-26_part10.txt',
 'sss_aaa_2013-09-26_part1.txt'];

对于上面的数组我需要排序如下。我怎么能这样做。

var result=['sss_aaa_2013-09-25_part1.txt',
 'sss_aaa_2013-09-25_part2.txt',
 'sss_aaa_2013-09-25_part3.txt',
 'sss_aaa_2013-09-25_part4.txt',
 'sss_aaa_2013-09-25_part12.txt',
 'sss_aaa_2013-09-26_part1.txt',
 'sss_aaa_2013-09-26_part10.txt'];

0 个答案:

没有答案