added sorting by each variable