completed using sort