Improved sorting method added.