-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME
More file actions
30 lines (22 loc) · 888 Bytes
/
README
File metadata and controls
30 lines (22 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Performs the IntroSort algorithm
(this is a beta version)
========================================
# Example using jQuery
var compare_function = function(val1, val2){
return val1 < val2;
};
var switching_function = function(val1, index1, val2, index2 ){
console.info( val1 + ' is now at position: ' + index1 );
console.info( val2 + ' is now at position: ' + index2 );
}
$.introSort( array, compare_function, switching_function );
# Example using no js framework
var compare_function = function(val1, val2){
return val1 < val2;
};
var switching_function = function(val1, index1, val2, index2 ){
console.info( val1 + ' is now at position: ' + index1 );
console.info( val2 + ' is now at position: ' + index2 );
}
introSort( array, compare_function, switching_function );
Thanks to: Ralph Unden (http://ralphunden.net/) for the algorithm