Sorting by priority. Also, update sorting when some parameters about it change.