I want to get the array from:
const foo = [
FOO_BAR_A_READ_SELF,
FOO_BAR_A_WRITE_SELF,
FOO_BAR_A,
FOO_BAR_A_READ_ALL,
FOO_BAR_A_WRITE_ALL,
FOO_BAR_B_READ_SELF,
FOO_BAR_B_WRITE_SELF,
FOO_BAR_B,
FOO_BAR_B_READ_ALL,
FOO_BAR_B_WRITE_ALL
]
to
const foo = [
FOO_BAR_A,
FOO_BAR_A_READ_SELF,
FOO_BAR_A_WRITE_SELF,
FOO_BAR_A_READ_ALL,
FOO_BAR_A_WRITE_ALL,
FOO_BAR_B,
FOO_BAR_B_READ_SELF,
FOO_BAR_B_WRITE_SELF,
FOO_BAR_B_READ_ALL,
FOO_BAR_B_WRITE_ALL
]
i tried to go with the length by splitting with the "_", but I never worked with the sort function that specific.
I only used desc and asc ( return 1 > -1 ) || ( return -1 > 1 )
Can someone can explain me how I can get the wanted result?