I think rearranging the values in the array is not necessary for just three values. Just compare all of them by subtracting; then you can decide which one is the median value:
// javascript:
var median_of_3 = function(a, b, c) {
return ((a-b)*(b-c) > -1 ? b : ((a-b)*(a-c) < 1 ? a : c));
}