I have an adjacency list of objects (rows loaded from SQL database with the key and it\'s parent key) that I need to use to build an unordered tree. It\'s guaranteed to not
SortedList is not a good container to use in this context. It is O(n) for insertion operations (the repeated calls to Add()), as it is internally represented as a flat list. Using Dictionary instead of SortedList will be a large improvement, as it is O(1) amortized insertion time.