So I have an array of strings to be sorted out.
Let's say I have this array:
let array = ["8AD", "8AB", "8A6", "8BC", "86F", "835", "81D"];
Now, there two kinds of sorting that needs to be implemented:
- Alphabetical characters are prioritized over numerical characters
- Numerical characters are prioritized over alphabetical characters
Now, I needed to sort using either of these two for every character.
So, a Numerical-Numerical-Alphabetical order would give me:
"81D","835","86F","8AB","8AD","8A6","8BC"
While a Numerical-Alphabetical-Numerical order would give me:
"8A6","8AB","8AD","8BC","81D","835","86F"
I'm thinking of assigning every single digit number and all characters to a double-digit integer:
let alpha = {
A= 11, B= 12 , C= 13 , D= 14 , E= 15 , F= 16 , G= 17 , H= 18 , I= 19 , J= 20 , K= 21,
L= 22 , M= 23 , N= 24 , O= 25 , P= 26 , Q= 27 , R= 28 , S= 29 , T= 30 , U= 31 , V= 32,
W= 33 , X= 34 , Y= 35 , Z= 36 , 0=37, 1= 38 , 2= 39 , 3= 40 , 4= 41 , 5= 42 , 6= 43 , 7= 44,
8= 45 , 9= 46 };
let numeral = {
0=11, 1=12, 2=13, 3=14, 4=15, 5=16, 6=17, 7=18, 8=19, 9=20, A=21,
B=22, C=23, D=24, E=25, F=26, G=27, H=28, I=29, J=30, K=31, L=32,
M=33, N=34, O=35, P=36, Q=37, R=38, S=39, T=40, U=41, V=42, W=43,
X=44, Y=45, Z=46 }
And then replacing every characters to whichever order is needed. Does anyone have a simpler or more efficient way to achieve what is needed to do?