mirror of
				https://github.com/janet-lang/janet
				synced 2025-11-04 09:33:02 +00:00 
			
		
		
		
	Merge pull request #1046 from dressupgeekout/charlotte_sort_doc
Explicitly mention that `sort-by` sorts a list in place.
This commit is contained in:
		@@ -839,15 +839,15 @@
 | 
				
			|||||||
  a)
 | 
					  a)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(defn sort
 | 
					(defn sort
 | 
				
			||||||
  ``Sort `ind` in-place, and return it. Uses quick-sort and is not a stable sort.
 | 
					  ``Sorts `ind` in-place, and returns it. Uses quick-sort and is not a stable sort.
 | 
				
			||||||
  If a `before?` comparator function is provided, sorts elements using that,
 | 
					  If a `before?` comparator function is provided, sorts elements using that,
 | 
				
			||||||
  otherwise uses `<`.``
 | 
					  otherwise uses `<`.``
 | 
				
			||||||
  [ind &opt before?]
 | 
					  [ind &opt before?]
 | 
				
			||||||
  (sort-help ind 0 (- (length ind) 1) (or before? <)))
 | 
					  (sort-help ind 0 (- (length ind) 1) (or before? <)))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(defn sort-by
 | 
					(defn sort-by
 | 
				
			||||||
  ``Returns `ind` sorted by calling
 | 
					  ``Sorts `ind` in-place by calling a function `f` on each element and
 | 
				
			||||||
  a function `f` on each element and comparing the result with `<`.``
 | 
					  comparing the result with `<`.``
 | 
				
			||||||
  [f ind]
 | 
					  [f ind]
 | 
				
			||||||
  (sort ind (fn [x y] (< (f x) (f y)))))
 | 
					  (sort ind (fn [x y] (< (f x) (f y)))))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user