Clojure – Sequences sort

Clojure sequences sort

In this guide, we will discuss Clojure Sequences sort. Returns a sorted sequence of elements.

Syntax

Following is the syntax.

(sort seq1)

Parameters − ‘seq1’ is the sequence list of elements.

Return Value − Returns a sorted sequence of elements.

Example

Following is an example of sort.

(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)

Output

The above program produces the following output.

(1 2 3 4 5)

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply