Public Vars

Back

sort (clj)

(source)

function

(sort coll) (sort comp coll)
Returns a sorted sequence of the items in coll. If no comparator is supplied, uses compare. comparator must implement java.util.Comparator. Guaranteed to be stable: equal elements will not be reordered. If coll is a Java array, it will be modified. To avoid this, sort a copy of the array.

Examples

clojure
(ns clojure.test-clojure.reducers
  (:require [clojure.core.reducers :as r]
            [clojure.test.generative :refer (defspec)]
            [clojure.data.generators :as gen])
  (:use clojure.test))


(deftest test-sorted-maps
  (let [m (into (sorted-map)
                '{1 a, 2 b, 3 c, 4 d})]
    (is (= "1a2b3c4d" (reduce-kv str "" m))
        "Sorted maps should reduce-kv in sorted order")
    (is (= 1 (reduce-kv (fn [acc k v]
                          (reduced (+ acc k)))
                        0 m))
        "Sorted maps should stop reduction when asked")))
HumbleUI/HumbleUI
(ns examples
  (:require
    [clojure.core.server :as server]
    [examples.7guis-converter]
    [examples.align]
    [examples.animation]
    [examples.backdrop]
    [examples.blur]
    [examples.bmi-calculator]
    [examples.button]
    [examples.calculator]
    [examples.canvas]
    [examples.canvas-shapes]
    [examples.checkbox]
    [examples.container]
    [examples.effects]
    [examples.errors]
    [examples.event-bubbling]
    [examples.framerate]
    [examples.grid]
    [examples.image-snapshot]
    [examples.label]
    [examples.oklch]
    [examples.paragraph]
    [examples.scroll]
    [examples.settings]
    [examples.slider]
    [examples.stack]
    [examples.state :as state]
    [examples.svg]
    [examples.text-field]
    [examples.text-field-debug]
    [examples.todomvc]
    [examples.toggle]
    [examples.tooltip]
    [examples.tree]
    [examples.treemap]
    [examples.wordle]
    [io.github.humbleui.app :as app]
    [io.github.humbleui.debug :as debug]
    [io.github.humbleui.paint :as paint]
    [io.github.humbleui.window :as window]
    [io.github.humbleui.ui :as ui]))

(def examples
  (sorted-map
    "7 GUIs: Converter" examples.7guis-converter/ui
    "Align" examples.align/ui
    "Animation" examples.animation/ui
    "Backdrop" examples.backdrop/ui
    "Blur" examples.blur/ui
    "BMI Calculator" examples.bmi-calculator/ui
    "Button" examples.button/ui
    "Calculator" examples.calculator/ui
    "Canvas" examples.canvas/ui
    "Canvas Shapes" examples.canvas-shapes/ui
    "Checkbox" examples.checkbox/ui
    "Container" examples.container/ui
    "Effects" examples.effects/ui
    "Errors" examples.errors/ui
    "Event Bubbling" examples.event-bubbling/ui
    "Framerate" examples.framerate/ui
    "Grid" examples.grid/ui
    "Image Snapshot" examples.image-snapshot/ui
    "Label" examples.label/ui
    "OkLCH" examples.oklch/ui
    "Paragraph" examples.paragraph/ui
    "Scroll" examples.scroll/ui
    "Settings" examples.settings/ui
    "Slider" examples.slider/ui
    "Stack" examples.stack/ui
    "SVG" examples.svg/ui
    "Text Field" examples.text-field/ui
    "Text Field Debug" examples.text-field-debug/ui
    "Todo MVC" examples.todomvc/ui
    "Toggle" examples.toggle/ui
    "Tooltip" examples.tooltip/ui
    "Tree" examples.tree/ui
    "Treemap" examples.treemap/ui
    "Wordle" examples.wordle/ui))

(def border-line
  (ui/rect (paint/fill light-grey)
    (ui/gap 1 0)))
      
(def app
  (ui/default-theme {}; :font-size 13
    ; :cap-height 10
    ; :leading 100
    ; :fill-text (paint/fill 0xFFCC3333)
    ; :hui.text-field/fill-text (paint/fill 0xFFCC3333)
    (ui/row
      (ui/vscrollbar
        (ui/column
          (for [[name _] (sort-by first examples)]
            (ui/clickable
              {:on-click (fn [_] (reset! examples.state/*example name))}
              (ui/dynamic ctx [selected? (= name @examples.state/*example)
                               hovered?  (:hui/hovered? ctx)]
                (let [label (ui/padding 20 10
                              (ui/label name))]
                  (cond
                    selected? (ui/rect (paint/fill 0xFFB2D7FE) label)
                    hovered?  (ui/rect (paint/fill 0xFFE1EFFA) label)
                    :else     label)))))))
      border-line
      [:stretch 1
       (ui/clip
         (ui/dynamic _ [name @examples.state/*example]
           (examples name)))])))
hraberg/deuce
(ns deuce.emacs.fileio
  (:use [deuce.emacs-lisp :only (defun defvar) :as el])
  (:require [clojure.core :as c]
            [clojure.string :as s]
            [clojure.java.io :as io]
            [deuce.emacs.buffer :as buffer]
            [deuce.emacs.data :as data]
            [deuce.emacs.eval :as eval]
            [deuce.emacs.editfns :as editfns])
  (:import [java.nio.file Files LinkOption
            NoSuchFileException]
           [deuce.emacs.data Buffer BufferText])
  (:refer-clojure :exclude []))

(defvar write-region-annotate-functions nil
  "A list of functions to be called at the start of `write-region'.
  Each is passed two arguments, START and END as for `write-region'.
  These are usually two numbers but not always; see the documentation
  for `write-region'.  The function should return a list of pairs
  of the form (POSITION . STRING), consisting of strings to be effectively
  inserted at the specified positions of the file being written (1 means to
  insert before the first byte written).  The POSITIONs must be sorted into
  increasing order.

(defun file-regular-p (filename)
  "Return t if FILENAME names a regular file.
  This is the sort of file that holds an ordinary stream of data bytes.
  Symbolic links to regular files count as regular files.
  See `file-symlink-p' to distinguish symlinks."
  (el/check-type 'stringp filename)
  (Files/isRegularFile (.toPath (io/file (expand-file-name filename))) (make-array LinkOption 0)))
hraberg/deuce
(ns deuce.emacs.dired
  (:use [deuce.emacs-lisp :only (defun defvar)])
  (:require [clojure.core :as c]
            [clojure.java.io :as io]
            [deuce.emacs-lisp.cons :as cons])
  (:import [java.io File])
  (:refer-clojure :exclude []))

(defun directory-files (directory &optional full match nosort)
  "Return a list of names of files in DIRECTORY.
  There are three optional arguments:
  If FULL is non-nil, return absolute file names.  Otherwise return names
   that are relative to the specified directory.
  If MATCH is non-nil, mention only file names that match the regexp MATCH.
  If NOSORT is non-nil, the list is not sorted--its order is unpredictable.
   Otherwise, the list returned is sorted with `string-lessp'.
   NOSORT is useful if you plan to sort the result yourself."
  (cons/maybe-seq
   ((if nosort identity sort)
    (filter (if match
              #(re-find (re-pattern
                         ((ns-resolve 'deuce.emacs.search
                                      'emacs-regex-to-java) match)) %)
              identity)
            (map (fn [^File f]
                   (if full
                     (.getCanonicalPath f)
                     (.getName f)))
                 (.listFiles (io/file directory)))))))

(defun directory-files-and-attributes (directory &optional full match nosort id-format)
  "Return a list of names of files and their attributes in DIRECTORY.
  There are four optional arguments:
  If FULL is non-nil, return absolute file names.  Otherwise return names
   that are relative to the specified directory.
  If MATCH is non-nil, mention only file names that match the regexp MATCH.
  If NOSORT is non-nil, the list is not sorted--its order is unpredictable.
   NOSORT is useful if you plan to sort the result yourself.
  ID-FORMAT specifies the preferred format of attributes uid and gid, see
  `file-attributes' for further documentation.
  On MS-Windows, performance depends on `w32-get-true-file-attributes',
  which see."
  )
hraberg/deuce
(ns deuce.emacs.charset
  (:use [deuce.emacs-lisp :only (defun defvar)])
  (:require [clojure.core :as c]
            [deuce.emacs.alloc :as alloc]
            [deuce.emacs.fns :as fns]
            [deuce.emacs-lisp.globals :as globals])
  (:refer-clojure :exclude []))

(defun sort-charsets (charsets)
  "Sort charset list CHARSETS by a priority of each charset.
  Return the sorted list.  CHARSETS is modified by side effects.
  See also `charset-priority-list' and `set-charset-priority'."
  )
fluree/db
(ns json-ld
  (:require [fluree.db.method.ipfs.core :as ipfs]
            [fluree.db.db.json-ld :as jld-db]
            [fluree.db.json-ld.transact :as jld-tx]
            [clojure.core.async :as async]
            [fluree.db.flake :as flake]
            [fluree.db.json-ld.api :as fluree]
            [fluree.db.util.async :refer [<?? go-try channel?]]
            [fluree.db.query.range :as query-range]
            [fluree.db.constants :as const]
            [fluree.db.dbproto :as dbproto]
            [fluree.db.did :as did]
            [fluree.db.conn.proto :as conn-proto]
            [fluree.db.util.json :as json]
            [fluree.json-ld :as json-ld]
            [fluree.db.indexer.default :as indexer]
            [fluree.db.indexer.proto :as idx-proto]
            [fluree.db.util.log :as log]))

  (-> (fluree/db ledger)
      :schema
      :refs
      sort)

  (->> (fluree/db ledger)
       :schema
       :pred
       vals
       set
       (filter #(true? (:ref? %)))
       (map :id)
       sort)