# R Error in sort.int(x, na.last, decreasing, …) : ‘x’ must be atomic (2 Examples)

In this article you’ll learn how to handle the “Error in sort.int(x, na.last = na.last, decreasing = decreasing, …) : ‘x’ must be atomic” in the R programming language.

## Creation of Exemplifying Data

x <- list(1:5, # Constructing example list 3:1, 5) x # Displaying example list # [[1]] # [1] 1 2 3 4 5 # # [[2]] # [1] 3 2 1 # # [[3]] # [1] 5 |

x <- list(1:5, # Constructing example list 3:1, 5) x # Displaying example list # [[1]] # [1] 1 2 3 4 5 # # [[2]] # [1] 3 2 1 # # [[3]] # [1] 5

## Example 1: Replicating the Error in sort.int(x, na.last = na.last, decreasing = decreasing, …) : ‘x’ must be atomic

sort(x) # Sorting list does not work |

sort(x) # Sorting list does not work

## Example 2: Solving the Error in sort.int(x, na.last = na.last, decreasing = decreasing, …) : ‘x’ must be atomic

sort(unlist(x)) # Sorting vector works fine # [1] 1 1 2 2 3 3 4 5 5 |

sort(unlist(x)) # Sorting vector works fine # [1] 1 1 2 2 3 3 4 5 5