completed sort by functionality