misc/
ajs_random_sort.pro
topajs_random_sort
result = ajs_random_sort(input [, min=min] [, max=max] [, seed=seed])
Return random indices, or sort an array into random order
ajs_random_sort(n) returns a random permutation of the integers 0 to (n - 1)
ajs_random_sort(n, min=min, max=max) returns n (different) random integers between min and (max - 1)
ajs_random_sort(array) returns the elements of array in a random order
Parameters
- input in required
Either (1) A single integer giving the number of array indices to return or (2) an input array to be sorted into random order
Keywords
- min in optional default=0
Used with a single integer input, this is the minimum array index that may be returned.
- max in optional default=input
Used with a single integer input, this number ** - 1 ** is the maximum array index that may be returned.
- seed in optional
Seed for randomu
Examples
print, ajs_random_sort([1, 2, 3])
1 2 3
print, ajs_random_sort(4)
3 1 0 2
print, ajs_random_sort(4, min=10, max=15)
12 10 13 14
Author information
History: |
22 Apr 2008 Written, Anthony Smith |
File attributes
Modifcation date: | Fri Jun 6 08:19:26 2008 |
Lines: | 66 |
Docformat: | rst rst |