1
I’m having a hard time organizing this array of mine:
$array = [];
$array[
"T3497012@CHOSTBRHDDSB@EICM_BORA@BPHS@Bamz",
"T3497012@BHOSTBRHDDSB@EICM_BORA@BPHS@Bamz",
"T3497012@AHOSTBRHDDSB@EICM_BORA@BPHS@Bamz",
"T3497012@AHOSTBRHDDSB@EICM_BORB@BPHS@Aama",
"T3497012@AHOSTBRHDDSB@EICM_BORC@APHS@cama",
"T2497123@DHOSTBRHDDSB@CICM_BORD@APHS@camb",
"T2497123@EHOSTBRHDDSB@BICM_BORE@APHS@camc",
"T5557012@FHOSTBRHDDSB@AICM_BORF@APHS@camd"
];
Each word of an item means something. For example in the item:T3497012@CHOSTBRHDDSB@EICM_BORA@BPHS@Bamz
T3497012
is the user id. CHOSTBRHDDSB
is a host, EICM_BORA
is a system, BPHS
is a type and Bamz
is a layer.
I need to sort all items in this array alphabetically, but there are some criteria:
alphabetical order first in systems resulting the array like this:
"T5557012@FHOSTBRHDDSB@AICM_BORF@APHS@camd",
"T2497123@EHOSTBRHDDSB@BICM_BORE@APHS@camc",
"T2497123@DHOSTBRHDDSB@CICM_BORD@APHS@camb",
"T3497012@CHOSTBRHDDSB@EICM_BORA@BPHS@Bamz",
"T3497012@BHOSTBRHDDSB@EICM_BORA@BPHS@Bamz",
"T3497012@AHOSTBRHDDSB@EICM_BORA@BPHS@Bamz",
"T3497012@AHOSTBRHDDSB@EICM_BORB@BPHS@Aama",
"T3497012@AHOSTBRHDDSB@EICM_BORC@APHS@cama"
First the system AICM_BORA
and lastly the EICM_BORA
Then I need to put it in order based on guy, being like this:
"T5557012@FHOSTBRHDDSB@AICM_BORF@APHS@camd",
"T2497123@EHOSTBRHDDSB@BICM_BORE@APHS@camc",
"T2497123@DHOSTBRHDDSB@CICM_BORD@APHS@camb",
"T3497012@AHOSTBRHDDSB@EICM_BORC@APHS@cama",
"T3497012@CHOSTBRHDDSB@EICM_BORA@BPHS@Bamz",
"T3497012@BHOSTBRHDDSB@EICM_BORA@BPHS@Bamz",
"T3497012@AHOSTBRHDDSB@EICM_BORA@BPHS@Bamz",
"T3497012@AHOSTBRHDDSB@EICM_BORB@BPHS@Aama"
Now I do the same process and order for layer:
"T5557012@FHOSTBRHDDSB@AICM_BORF@APHS@camd",
"T2497123@EHOSTBRHDDSB@BICM_BORE@APHS@camc",
"T2497123@DHOSTBRHDDSB@CICM_BORD@APHS@camb",
"T3497012@AHOSTBRHDDSB@EICM_BORC@APHS@cama",
"T3497012@AHOSTBRHDDSB@EICM_BORB@BPHS@Aama",
"T3497012@CHOSTBRHDDSB@EICM_BORA@BPHS@Bamz",
"T3497012@BHOSTBRHDDSB@EICM_BORA@BPHS@Bamz",
"T3497012@AHOSTBRHDDSB@EICM_BORA@BPHS@Bamz"
and lastly by hostname:
"T5557012@FHOSTBRHDDSB@AICM_BORF@APHS@camd",
"T2497123@EHOSTBRHDDSB@BICM_BORE@APHS@camc",
"T2497123@DHOSTBRHDDSB@CICM_BORD@APHS@camb",
"T3497012@AHOSTBRHDDSB@EICM_BORC@APHS@cama",
"T3497012@AHOSTBRHDDSB@EICM_BORB@BPHS@Aama",
"T3497012@AHOSTBRHDDSB@EICM_BORA@BPHS@Bamz",
"T3497012@BHOSTBRHDDSB@EICM_BORA@BPHS@Bamz",
"T3497012@CHOSTBRHDDSB@EICM_BORA@BPHS@Bamz"
tried many things but I believe that my lack of experience does not allow me a solution to this.
But want to make an ordering based on 4 criteria or 4 different sorts ?
– Isac