Clojure-sequences-sort

提供:Dev Guides
移動先:案内検索

Clojure-シーケンスの並べ替え

要素のソートされたシーケンスを返します。

構文

構文は次のとおりです。

(sort seq1)

パラメータ-「seq1」は要素のシーケンスリストです。

戻り値-要素のソートされたシーケンスを返します。

並べ替えの例を次に示します。

(ns clojure.examples.example
   (:gen-class))

;; This program displays Hello World
(defn Example []
   (def seq1 (seq [5 4 3 2 1]))
   (def seq2 (sort seq1))
   (println seq2))
(Example)

出力

上記のプログラムは、次の出力を生成します。

(1 2 3 4 5)