sorting by priority