Bug when adding a product on order

Sometimes, the $order->getProducts() method does not return the order_details in ascending order.
So when fetching de end() of the array, it wont always be the last product added, and the bag product was displayed.
This is why is force ordering by keys (containing the id_order_detail field value).