mirror of
				https://github.com/janet-lang/janet
				synced 2025-10-30 23:23:07 +00:00 
			
		
		
		
	sort doc
				
					
				
			Clarify doc for `sort` and `sorted`. Also in `sort`, changed arg name.
This commit is contained in:
		| @@ -778,9 +778,12 @@ | ||||
|   a) | ||||
|  | ||||
| (defn sort | ||||
|   "Sort an array in-place. Uses quick-sort and is not a stable sort." | ||||
|   [a &opt before?] | ||||
|   (sort-help a 0 (- (length a) 1) (or before? <))) | ||||
|   ``Sort `ind` in-place, and return it. Uses quick-sort and is not a stable sort. | ||||
|    | ||||
|   If a `before?` comparator function is provided, sorts elements using that; | ||||
|   otherwise uses `<`.`` | ||||
|   [ind &opt before?] | ||||
|   (sort-help ind 0 (- (length ind) 1) (or before? <))) | ||||
|  | ||||
| (defn sort-by | ||||
|   ``Returns `ind` sorted by calling | ||||
| @@ -789,7 +792,10 @@ | ||||
|   (sort ind (fn [x y] (< (f x) (f y))))) | ||||
|  | ||||
| (defn sorted | ||||
|   "Returns a new sorted array without modifying the old one." | ||||
|   ``Returns a new sorted array without modifying the old one. | ||||
|    | ||||
|   If a `before?` comparator function is provided, sorts elements using that; | ||||
|   otherwise uses `<`.`` | ||||
|   [ind &opt before?] | ||||
|   (sort (array/slice ind) before?)) | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 John Gabriele
					John Gabriele