Better! …but that jumps out at me as looking very non-D.R.Y, as it’s close to being a copy-paste of the same logic that’s already used elsewhere.
Also, a quick glance at the docs for the real JS function shows that you’ve overlooked both the return value and the optional argument that it can take, which allows a custom sort function to be provided.
Given that it has a custom sort argument, probably a better approach would be to always use a JS comparison function: either the custom one if present, or a default one. That way the default comparison function would be a simple line of JS compiled using the parser, which would automatically use the existing < operator, rather than needing to re-implement a comparator like you’ve done here.
BTW you should avoid C-style casts in general, but never, never use them with non-primitive types, and particularly in templated code. Always use a static_cast, which will cause errors if you accidentally do something silly.
(Not meaning to sound critical - intending this as friendly coding tuition for you! )