I want to order an ArrayList of vehicles according to their license plate. The registration has a format of 4 numbers followed by 3 capital letters. For example: String matricula = 1234QQQ I have implemented the Comparable interface in my Vehicle class and I am designing the compareTo method. I have managed to get it to order based on numbers but I cannot get it to order based on letters. So the license plates 1111ZZZ and 1111AAA put the one I entered first in front of me. However 2222RRR and 1111RRR if you order them correctly. The image shows: -- Vehicle implements Comparable
-- The compareTo method. I think I have the problem in the else, since the numbers order them well.
--The ListarVehiculos method of the dealership class where I call the sort method and pass the name of the ArrayList as a parameter (dealership)
Thank you very much for the feedback. I believe that I have the problem in the else, when I try to order the "string" part of the registration. In the attached image I have compiled what refers to the order of the ArrayList, and I reiterate that part of the CompareTo method is fine because it orders the numerical part of the license plate. I assume that's what you mean by asking it to compile and run. Thank you
The code that orders the license plates using the complete String: