Implemented sort and saving