From 0f89ff3d515bafea621e70785fbf1240d0f8a989 Mon Sep 17 00:00:00 2001 From: Oleg Mifle Date: Mon, 18 Oct 2021 20:47:29 +0300 Subject: [PATCH] Create sort_array_by_map --- php/sort_array_by_map | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 php/sort_array_by_map diff --git a/php/sort_array_by_map b/php/sort_array_by_map new file mode 100644 index 00000000..a822d960 --- /dev/null +++ b/php/sort_array_by_map @@ -0,0 +1,32 @@ + 'text message 2', + 'FIRS_MESSAGE' => 'text message 1', + 'THIRD_MESSAGE' => 'text message 3', +]; + +$map = ['FIRS_MESSAGE', 'SECOND_MESSAGE', 'THIRD_MESSAGE']; + +sortByIdsMap($items, $map); + +print_r($items); + +/* +Array +( + [FIRS_MESSAGE] => text message 1 + [SECOND_MESSAGE] => text message 2 + [THIRD_MESSAGE] => text message 3 +) +*/