gallery sort fix