@@ -442,6 +442,37 @@ TEST(MathTest, Sort) {
442442 }
443443}
444444
445+ // -------------------------------------------------------------------------------------------------
446+ TEST (MathTest, InplaceSort) {
447+ {
448+ arr_real x1 = {4 , 1 , 2 , 5 , 6 , 7 , 3 , 3 };
449+ sort (inplace (x1));
450+ ASSERT_EQ_ARR_REAL (x1, arr_real{1 , 2 , 3 , 3 , 4 , 5 , 6 , 7 });
451+ ASSERT_TRUE (issorted (x1));
452+ }
453+ {
454+ arr_real x1 = {4 , 1 , 2 , 5 , 6 , 7 , 3 , 3 };
455+ sort (inplace (x1), Direction::Descend);
456+ ASSERT_EQ_ARR_REAL (x1, arr_real{7 , 6 , 5 , 4 , 3 , 3 , 2 , 1 });
457+ ASSERT_TRUE (issorted (x1, Direction::Descend));
458+ ASSERT_FALSE (issorted (x1, Direction::Ascend));
459+ }
460+ {
461+ arr_real x1 = {0 , 1 , 2 , 3 , 4 , 5 };
462+ sort (inplace (x1));
463+ ASSERT_EQ_ARR_REAL (x1, arr_real{0 , 1 , 2 , 3 , 4 , 5 });
464+ ASSERT_TRUE (issorted (x1));
465+ ASSERT_FALSE (issorted (x1, Direction::Descend));
466+ }
467+ {
468+ arr_real x1 = {5 , 4 , 3 , 2 , 1 , 0 };
469+ sort (inplace (x1), Direction::Descend);
470+ ASSERT_EQ_ARR_REAL (x1, arr_real{5 , 4 , 3 , 2 , 1 , 0 });
471+ ASSERT_TRUE (issorted (x1, Direction::Descend));
472+ ASSERT_FALSE (issorted (x1, Direction::Ascend));
473+ }
474+ }
475+
445476// -------------------------------------------------------------------------------------------------
446477TEST (MathTest, Factor) {
447478 ASSERT_EQ_ARR_REAL (factor (0 ), arr_int{0 });
0 commit comments