Purpose: Four‐dimensional (4D) computed tomography (CT) has been widely used as a tool to characterize respiratory motion in radiotherapy. The two most commonly used 4DCT algorithms sort images by respiratory phase or displacement into a predefined number of bins, and are prone to image artifacts at transitions between bed positions. The purpose of this work is to demonstrate a method of reducing motion artifacts in 4DCT by incorporating anatomic similarity into phase or displacement based sorting protocols. Methods: Ten patient datasets were retrospectively sorted using both displacement and phase based sorting algorithms. Conventional sorting methods allow selection of only the nearest neighbor image in time or displacement within each bin. In our method, for each bed position either the displacement or the phase defines the center of a bin range about which several candidate images are selected. The two dimensional correlation coefficients between slices bordering the interface between adjacent couch positions are then calculated for all candidate pairings. Two slices have a high correlation if they are anatomically similar. Candidates from each bin are then selected to maximize the slice correlation over the entire data set using Dijkstraˈs shortest path algorithm. To assess the reduction of artifacts, two thoracic radiation oncologists independently compared the re‐sorted 4D datasets pair‐wise with conventionally sorted datasets, blinded to the sorting method, to choose which had the least motion artifacts. Agreement between reviewers was evaluated using the weighted kappa score. Results: Anatomically based image selection resulted in 4DCT datasets with significantly reduced motion artifacts with both displacement (P=0.0063) and phase sorting (P=0.00022). The reviewers agreed 34 times and disagreed 6 times. Conclusions: Sorting using anatomic similarity significantly reduces 4DCT motion artifacts compared to conventional phase or displacement based sorting. This improved sorting algorithm is a straightforward extension of the two most common 4DCT sorting algorithms.