Hi guys,
I am wondering how can I create a sorted linked list, without using Collection.sort(). Is there a way I can add element in a list in a sorted fashion?
alkeshtech
0
Light Poster
Recommended Answers
Jump to PostWhenever you add an element, iterate thru the existing list elements until you find the right place to insert the new element. That way the list will always be in sorted order
Jump to PostI too am trying to figure this one out. I am looping through the list but what happens when you get to the end() and the condition is never met for the insert?
In that case the new element must belong on the end of the list (ie sorts after …
All 5 Replies
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
powerage
0
Newbie Poster
powerage
0
Newbie Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
Andreas Hollman
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.