I'm having a hard time organizing this array:
$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, however there are some criteria:
alphabetical order first in the systems resulting in 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 finally the EICM_BORA
Then I need to put in order based on type , thus:
"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 I command by 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 finally 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"
I tried many things but I believe that my lack of experience does not allow me a solution to this.