Sort function leaking options var to global scope