Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • $\begingroup$ Perhaps it's an under-specified question, but my interpretation is that the next pointer is to another position in the array. So every swap will involve changing the values you're sorting by, or breaking the links. This is not a complete solution. $\endgroup$ Commented Jul 3 at 19:44
  • $\begingroup$ An in-place sort is inefficient: you already know where each node belongs, so you can reorder in O(n) time, with just a single pass through the list. $\endgroup$
    – Mark
    Commented Jul 3 at 21:37
  • 2
    $\begingroup$ There’s the minor problem here that the sort key (the address of the node) changes throughout the sorting process. $\endgroup$
    – gnasher729
    Commented Jul 4 at 4:58