跳轉到內容

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
華夏公益教科書