add dimension order algorithm