<p>I'm looking for an elegant, high performance solution to the following problem. </p>

<p>There are 256 linked lists.  </p>

<ul>
<li>Each list contains the same types of object that among other things holds a whole number that is used to define a sort order.</li>
<li>All numbers across all lists are unique</li>
<li>Each individual list is sorted in ascending order by these numbers</li>
</ul>

<p>How would you create a single ascending ordered list from all the objects from the 256 original linked lists? I'd prefer not to brute force it, and have a few other ideas, but this seems like one of those problems that there's a standard, optimal solution for.</p>

You could use a priority queue that holds the “topmost” item of each of the 256 linked lists. This “topmost” item is the one that is scheduled to be inserted into the resulting list. This way, you can just take the smallest element from the priority queue, insert it into your resulting queue, and insert its next element into the priority queue:
```
```
# Preprocessing:
result = list.new()
queue = priority_queue.new()

foreach (list in lists):
    queue.push(list.first())

# Main loop:
while (not queue.empty()):
    node = queue.pop()
    result.insert(node)
    if (node.next() != null):
        queue.push(node.next())
```
```