[3.8] Add sort on last applied template