跳转到内容

Perl 编程/关键字/sort

来自维基教科书,自由的教学资源
上一页: socketpair 关键字 下一页: splice

Thesortkeyword

[编辑 | 编辑源代码]

sortsorts theLISTalphabetically and returns the sorted list value when called from list context. The behaviour is undefined for a call from scalar context.

WithoutBLOCKorSUBNAME, the sort is done in standard string comparison order.SUBNAMEis the name of a subroutine that returns an integer less than, equal to, or greater than zero depending on the ordering of the elements in the list.SUBNAMEcan also be a scalar variable name where its value provides the name of or a reference to the subroutine. Instead of an existing subroutine, theBLOCKcan contain the code as an in-line subroutine without a name.

  sort SUBNAME LIST
  sort BLOCK LIST
  sort LIST
上一页: socketpair 关键字 下一页: splice
华夏公益教科书