Try:
result <- aggregate(Survived ~ Fare2 + Pclass + Sex, data=train, FUN=function(x) {sum(x)/length(x)})
result <- result[order(result$Survived,decreasing=T),]
This will give you the result in descending order of Survived
.
Alternatively, you could add a rank column:
result <- aggregate(Survived ~ Fare2 + Pclass + Sex, data=train, FUN=function(x) {sum(x)/length(x)})
result$rank <- rank(result$Survived)
result <- result[order(result$rank,decreasing=T),]
BTW: You're just calculating the mean in the function, so you could use:
aggregate(Survived ~ Fare2 + Pclass + Sex, data=train, mean)