I got a dataset with a list of keywords (1 keyword / row).
df$ALPHABETICAL <- sapply(strsplit(df$KEYWORD," "),function(x) paste(sort(x),collapse=" "))
df
# KEYWORD ALPHABETICAL
# 1 house blue blue house
# 2 blue house blue house
# 3 my blue house blue house my
# 4 this house is blue blue house is this
# 5 sky orange orange sky
# 6 orange sky orange sky
# 7 the orange sky orange sky the
data
df <- data.frame(KEYWORD = c(
'house blue',
'blue house',
'my blue house',
'this house is blue',
'sky orange',
'orange sky',
'the orange sky'),stringsAsFactors = FALSE)