1

Greetings Stackoverflow.

Let's say I have the following array:

[D35D] => D35D
[D35C] => D35C
[D14D] => D14D
[D14B] => D14B
[D14A] => D14A
[D13C] => D13C

Is there a way to sort the array by key and keeping the sorting descending but alphabetically? So the result array will be like this:

[D35C] => D35C
[D35D] => D35D
[D14A] => D14A
[D14B] => D14B
[D14C] => D14C
[D13C] => D13C
  • I also want to know!!! – RappY Dec 04 '18 at 14:39
  • Please define what you mean by "descending but alphabetically" exactly. Doesn't make a whole lot of sense. You probably want some `usort`/`uksort` function which takes your string apart and compares the numbers and trailing character separately…? – deceze Dec 04 '18 at 14:53
  • i think u dont have a unique key in first array to make the sort plz update it with the correct example to understand what you want – HamzaNig Dec 04 '18 at 14:56
  • @deceze its only for the last 3 chars in the keys, eg D35D and 35C. D That should be D35C and D35D – Andreas Therkildsen Dec 04 '18 at 14:56
  • @HamzaNig Take a look at the first array and then the result array. It should sort by the keys. EG in the first array key D35D comes before D35C. I want D35C to appear before D35D – Andreas Therkildsen Dec 04 '18 at 14:58
  • @deceze why you marked the question as duplicate , i have an working answer now i cant post my answer – HamzaNig Dec 04 '18 at 15:22
  • @AndreasTherkildsen sorry i have the answer but i cant posting because of the duplicate mark you can start a new question if you want the answer – HamzaNig Dec 04 '18 at 15:29
  • @HamzaNig could you send it to me via mail? I will provide you with the email. – Andreas Therkildsen Dec 05 '18 at 06:22
  • @AndreasTherkildsen ok sure , but i dont have ur email – HamzaNig Dec 05 '18 at 08:18
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/184748/discussion-between-hamzanig-and-andreas-therkildsen). – HamzaNig Dec 05 '18 at 10:54

0 Answers0