Sort Perl array in place

后端 未结 3 830
生来不讨喜
生来不讨喜 2020-12-06 00:03

I have a reference to an array (called $intervals) and I would like to sort the values in this array. It\'s possible that there could be a huge number of values

3条回答
  •  庸人自扰
    2020-12-06 00:40

    The second example will create a new reference:

    $x = [ qw( a c b ) ]; say $x; @$x = sort @$x; say $x; $x = [sort @$x]; say $x
    

    Reference.

提交回复
热议问题