utils: sort_and_truncate added
utils : modification
utils: sort_and_truncate function added