algorithm - Java program to alphanumeric sorting objects -


Java program for alphanumeric sorting objects

Please tell me how I can achieve the expected results

Expected output: B2D1D2D14E2

Actual output: B2D1D14D2E2

=== =========== =============================== < code> list & lt; Name & gt; Lst = new ArrayList & lt; & Gt; (); Lst.add (new name ("D", 1)); Lst.add (new name ("D", 14)); Lst.add (new name ("D", 2)); Lst.add (new name ("E", 2)); Lst.add (new name ("b", 2)); Comparison. Source (LCT, New Computter & lt; name & gt; () {@ Comparison of Override Public Int (name N1, Name N2) {// TODO Auto-Generated Method Stub String o1 = n1.getNm () + n1.getSeatnum (); String O2 = N 2.getNm () + n2.getSeatnum (); return to o1.compareTo (o2);}}}; (name name: lst) {System. Out.println (name.getNm () + name.getSeatnum ());}

===================== ===========

  name of the public class {private string nm; private int cittanum; public ent sisenum () {return sitenam;} public zero Setsetnatnam (int sitanem) {this.seatnum = seatnum;} public name (string nm) {super (); this.nm = nm;} public name (string nm, it sitenet) {super (); this.nm = nm ; This.seatnum = seatnum;} public string getNm () {return nm;} public null setnm (string nm) {this.nm = nm; compare letters compared to just your own:  
    

Compare Public Ent (name N1, name N2) {// Todo Auto-Generate The method used is stub en comparison = n1.g EtNm () Compare (n2.getNm ()); If (comparison == 0) {return Integer.compare (n1.getSeatnum (), n2.getSeatnum ()); } Other {comparison of return; }}

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -