1. use module class in py. 2. refine sort logic in js