如何对红色列表进行反向排序?

How can I reverse-sort a list in Red?

我一直在玩 Red,我想出了如何对列表进行排序:

--== Red 0.5.1 ==-- 
Type HELP for starting information. 

red>> list: [1 9 6 8]
== [1 9 6 8]
red>> sort list
== [1 6 8 9]

我想将此列表向后排序。我怎样才能做到这一点?我尝试了各种组合:

red>> sort !list 
*** Script error: !list has no value
*** Where: sort
red>> !sort list
*** Script error: !sort has no value
*** Where: try
red>> sort reverse list
== [1 6 8 9]
red>> sort list reverse
*** Script error: reverse is missing its series argument
*** Where: reverse
red>> reverse sort list
== [9 8 6 1]

它是基于堆栈的,所以你需要从右到左阅读它。你可以写成:

red>> reverse (sort list)

想象一下更好。

SORT 有一个 /reverse 细化,使您能够实现您想要的:

red>> sort/reverse [1 9 6 8]
== [9 8 6 1]

还要注意 SORT 修改它的参数。

您可以使用集成的帮助系统了解有关 SORT(或任何其他函数)如何工作的更多信息:

red>> help sort

USAGE:
    sort series  /case  /skip  size  /compare  comparator  /part  length  /all  /reverse  /stable

DESCRIPTION:
     Sorts a series (modified); default sort order is ascending. 
     sort is of type: action!

ARGUMENTS:
     series  [series!]

REFINEMENTS:
     /case => Perform a case-sensitive sort.
     /skip => Treat the series as fixed size records.
         size  [integer!]
     /compare => Comparator offset, block or function.
         comparator  [integer! block! any-function!]
     /part => Sort only part of a series.
         length  [number! series!]
     /all => Compare all fields.
     /reverse => Reverse sort order.
     /stable => Stable sorting.