I can’t remember where this came in handy, but I know I needed it at some point. This snippet does exactly what it says, sorts a JavaScript array by the supplied key value.