Hey there, I'm looking in to using the sort method for arrays. I have a class of grocery items and 3 arrays of 25 items. I need to sort one by the aisle number, another by price, and the last alphabetically. Can I do this with my class or do I need to alter it in some way or should I write my own sorting method?
Thank you for any help you have to offer!Code:class GroceryItem{ public String name; public double price; public int stockNumber, orderNumber, row, numItems; public long SKU; Random generator = new Random(); public GroceryItem(String name, String price, String row){ this.name = name; this.price = Double.parseDouble(price); this.row = Integer.parseInt(row); this.stockNumber = generator.nextInt(50); this.orderNumber = generator.nextInt(20); this.SKU = generator.nextInt(1000000); } public void purchase(){ this.stockNumber -= 1; this.numItems += 1; } }



Reply With Quote
Bookmarks