updated sorting to be more robust and cleaned up some stuff in languages

And my use case (Custom User Data) now appears to work properly.