Fix sort order causing crash when multiple items are selected