日本語 English
株式会社ヒューリンクス
TEL:03-5642-8384
営業時間:9:00-17:30

sort

範囲として与えられた数値を昇順に並び替えます。または、範囲として与えられた数値をデータのブロックとともに昇順で並べ替えます。

構文

sort(block, range)

引数 range には 1つの範囲 ({} で指定) 、もしくは、ワークシートの1列を指定します。引数 block を省略すると、引数 range のデータが昇順で並べられます。

例 1

  • col(2) = sort(col(1))は、列1に含まれる要素を昇順に並べ替えて、列2に配置します。降順に並べ替えるには、以下のようにカスタム関数:
    reverse(x) = x[data(size(x),1)]

    を定義し、並べ替えた結果に適用します。例えば、reverse(sort(x)) は範囲 x を降順に並べ替えます。

例 2

  • 次の演算:
    block(3,1) = sort(block(1,1,2,size(col(2))),col(2))

    では、列2をキー列として列1と2を並べ替え、結果を列 3 と 4 に返します。

関連情報

sort

This function can be used to sort a range of numbers in ascending order, or a range of numbers in ascending order together with a block of data.

Syntax

sort(block,range)

The range argument can be either a specified range (indicated with the { } brackets) or a worksheet column. If the block argument is omitted, the data in range is sorted in ascending order.

Example 1

  • The operation col(2) = sort(col(1)) returns the contents of column 1 arranged in ascending order and places it in column 2. To reverse the order of the sort, you can create a custom function:
    reverse(x) = x[data(size(x),1)]

    then apply it to the results of the sort. For example, reverse(sort(x)) sorts range x in descending order.

Example 2

  • The operation:
    block(3,1) = sort(block(1,1,2,size(col(2))),col(2))

    sorts data in columns 1 and 2 using column 2 as the key column and places the sorted data in columns 3 and 4.

関連情報