- $sortedVisibleShelfBooks = $shelf->visibleBooks()->get()
- ->sortBy($sort === 'default' ? 'pivot.order' : $sort, SORT_REGULAR, $listOptions->getOrder() === 'desc')
+ $sortedVisibleShelfBooks = $shelf->visibleBooks()
+ ->reorder($sort === 'default' ? 'order' : $sort, $listOptions->getOrder())
+ ->get()