Find the second lowest number in an array?
Actionscript 2, Flash 6
I just learned enough about arrays to find the lowest number in a group, and I'm pretty pumped.
But now how do I find the SECOND lowest?
I've found plenty on finding max and mins, but finding the runner up yields an informational desert!
This is what's getting me the lowest so far:
Actionscript Code:
minValue = function (array) {
mn = array[0];
for (i=0; i<array.length; i++) {
if (array[i]<mn) {
mn = array[i];
}
}
return mn;
};
k = new Array();
k = [varible1,variable2,variable3,variable5,etc];
smallest_textbox = (minValue(k));
// and happily, the smallest variable is displayed in the textbox
Any ideas or suggestions on how to think about this problem?
I need the silver medal, #2, runner up!
+Farm