FAQ
 
 
Cover  \ Exhibition  \ Learning  \ Reference  \ Download  \ Discourse   
      Language \ Environment \ Libraries \ Comparison
 
   
   
Abridged (A-Z) \ Complete (A-Z)  
   
  Reference for Processing (BETA) version 91+. If you have a previous version, use the reference included with your software. If you see any errors or have any comments, let us know.  
Name  

sort()

   
Examples  
float a[] = { 3.4, 3.6, 2, 0, 7.1 }; 
a = sort(a); 
for (int i = 0; i < a.length; i++) { 
  println(a[i]); 
} 
 


String s[] = { "deer", "elephant", "bear", "aardvark", "cat" }; 
s = sort(s); 
print(s);  // Prints "aardvark bear cat deer elephant" 


String s[] = { "deer", "elephant", "bear", "aardvark", "cat" }; 
s = sort(s, 3); 
print(s);  // Prints "bear dear elephant" 
 

Description   Sorts an array of numbers from smallest to largest and puts an array of words in alphabetical order. The original array is not modified and the re-ordered array is returned. The count parameter states the number of elements to sort. For example if there are 12 elements in an array and if count is the value 5, only the first five elements on the array will be sorted.
   
Syntax  
sort(dataArray)
sort(dataArray, count)
   
Parameters  
dataArray   String[], int[], or float[]

count   int:

   
Returns   Array (same datatype as the input)
   
Usage   Web & Application
   
Related   reverse()
 
 






   
 
Updated: Fri Jul 15 16:36:09 PDT 2005
 
 








Creative Commons License
 
  Processing is an open project initiated by Ben Fry and Casey Reas  
  © Info