implement sort and autosort