Improved list sorting and added func to create list