Add column "a"
> df["a"] <- 0
> df
b c d a
1 1 2 3 0
2 1 2 3 0
3 1 2 3 0
Sort by column using colum name
> df <- df[c('a', 'b', 'c', 'd')]
> df
a b c d
1 0 1 2 3
2 0 1 2 3
3 0 1 2 3
Or sort by column using index
> df <- df[colnames(df)[c(4,1:3)]]
> df
a b c d
1 0 1 2 3
2 0 1 2 3
3 0 1 2 3