Python Sort List Using Function Javascript Mozilla