How can I sort an array or table by column in Perl?

前端 未结 3 2052
孤独总比滥情好
孤独总比滥情好 2020-12-18 06:10

I\'ve been looking everywhere for an answer to this, and I just can\'t get it to work.

I have an input file that is read into an array using Perl. The file is a text

3条回答
  •  执笔经年
    2020-12-18 06:37

    You might also like the nsort_by function from List::UtilsBy:

    use List::UtilsBy 'rev_nsort_by';
    
    my @sorted = rev_nsort_by { (split(' ', $_))[4] } @input;
    

提交回复
热议问题