Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

Sorting in an ascending order

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello! This is my first post I hope it goes well (actually second but there I posted in the wrong forum) so basically I want to make this code that I have insert people in ascending order. For example I input Berta Andy Cody, the outpust should be Andy Berta Cody. Here is the code, what changes do I need to implement so that the code posts in ascending order.
 
Marshal
Posts: 68904
275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

I have deleted the other post.
Why does the List implement PhoneBook? Is is a List at all? Please explain what that class is supposed to represent; we need to know what you want to do before you try to work out how to do it.
 
Aiden Damantis
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey thank you! Well it implements the interface PhoneBook while the methods (insert,delete) are within that interface. This class PhoneBookList inserts deletes,looks up people.There is also a Person class that is wrapped up in this static final Node.Now what I want is this insert method is inserting people within the list.I want the people to be inserted in ascending order.Maybe it was a mistake posting the entire code but the change most likely has to be in the insert method.
 
Aiden Damantis
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So maybe removing one of those lines?
 
Marshal
Posts: 25436
65
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Aiden Damantis wrote:So maybe removing one of those lines?



Changing your code at random to see what happens is one way to write programs. Just not a very good way. What you need to do now is to decide where in the code you're ready to move to the next node, and put that code there and there only.
 
A timing clock, fuse wire, high explosives and a tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic