If it is the variables names of the smallest and largest values that you require, then using ECMA5 methods you could do something like this. You will need to use an object
to be able to get names rather than individual variables.
Javascript
function getNamesSmallestToLargestByValue(thisObj) {
return Object.keys(obj).map(function (name) {
return [name, this[name]];
}, thisObj).sort(function (x, y) {
return x[1] - y[1];
}).map(function (element) {
return element.shift();
});
}
var obj = {
'a': 11,
'b': 23,
'c': 8
};
console.log(getNamesSmallestToLargestByValue(obj));
Output
["c", "a", "b"]
On jsFiddle
As you can see, the returned array will give you the names sorted from smallest to largest by their associated values. Therefore the first element is the name of the smallest value and last element is the name of the largest value.