ihr seid meine letzte hoffnung hier. ihc hab bis heut nacht um 3 an nem sortieralgorythmus gesessen und kriegs net gebacken.
kurz zur erklärung. das ist eine arraylist vom typ integer. darin sind artikelnummer gespeichert. mit den artikelnnummern bekommt man die artikel. die sollen alphabetisch sortiert werden.
ArrayList<Integer> allAuctionArticles = applicationLogicAccess.ApplicationLogicAccess.getA llAuctionArticles(); ArrayList<Integer> allSaleArticles = applicationLogicAccess.ApplicationLogicAccess.getA llDirectSales(); ArrayList<Integer> giveToHTML = new ArrayList(); applicationLogicAccess.ApplicationLogicAccess .getAllDirectSales(); int size1 = allAuctionArticles.size(); //AuktionsArtikel sortieren for (int j = 0; j < size1; j ++) { for (int i = 0; i < size1 -2; i ++) { System.out.println(allAuctionArticles); try { String a = applicationLogicAccess.ApplicationLogicAccess.getA rticleToString(allAuctionArticles.get(i)); String b = applicationLogicAccess.ApplicationLogicAccess.getA rticleToString(allAuctionArticles.get(i+1)); String a1 = a.substring( 7, 8 ); String b1 = b.substring( 7, 8 ); int lexicalSize1 = b1.compareToIgnoreCase("A"); int lexicalSize2 = a1.compareToIgnoreCase("A"); System.out.println(lexicalSize1); System.out.println(lexicalSize2); if (lexicalSize1 > lexicalSize2 || lexicalSize1 == lexicalSize2) { int aa = allAuctionArticles.get(i); giveToHTML.add(aa); int bb = allAuctionArticles.get(i+1); giveToHTML.add(bb); i++; } if (lexicalSize1 < lexicalSize2) { giveToHTML.add(allAuctionArticles.get(i)); giveToHTML.add(allAuctionArticles.get(i+1)); i++; } } catch (ArticleNotFoundException e) { quarry(); } } allAuctionArticles.clear(); System.out.println("vor dem Clear"+allAuctionArticles); System.out.println(giveToHTML); allAuctionArticles = (ArrayList<Integer>) giveToHTML.clone(); giveToHTML.clear(); System.out.println(allAuctionArticles); }
aber der sortiert einfach überhaupt nicht kann mir da jemand helfen? (sry, würd den gern nch erklären, muss jetzt aber erstmal meinen zug erwischen. ist aber vom prinzip her nen bubblesort (oder soll einer sein. der holt sich von jedem artikel den ersten buchstaben des artikels und gleicht die ab (der lexikalisce vergleich stimmt auch) aber fügt irgendwie käse in die finale tabelle ein. und den fehler find ich nicht.).
danke im vorraus,
lod14