Moves specified elements to the front and/or back of a list while preserving the relative order of all other elements.

setOrderList(l, first = NULL, last = NULL)

Arguments

l

A named list.

first

A character vector of names to move to the front.

last

A character vector of names to move to the back.

Value

A list with reordered elements. Names that do not exist in l are silently ignored.

Examples

my_list <- list(c = 3, a = 1, d = 4, b = 2)
setOrderList(my_list, first = c("a", "b"), last = "c")
#> $a
#> [1] 1
#> 
#> $b
#> [1] 2
#> 
#> $d
#> [1] 4
#> 
#> $c
#> [1] 3
#>