orders_by function rearrage