Fixed the hook to sort items.