Fixed sorting issue with key=len