Hacker News new | past | comments | ask | show | jobs | submit login

Yes, I noted that list container. If I need a sorted list, do I need to do that myself (which is OK though not ideal)? Or again there is some other container that can work possibly with a wrapper around it to emulate a sorted linked list?



I think the thing to do is just to write a function to keep stepping through the list until you find the right place to insert, and then just use container/list.

Sorry to be "that guy" who questions the question, but sorted lists aren't really a great data structure. As you probably already know, insertion is O(N), where N is the total number of elements in the list. It might be better just to use the GoLRB library, which provides some always-sorted tree structures.


You are right. I had a very specific case where I needed a sorted list. I do not recall why anymore.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: