Fixed sorting for bags