function(                                                      # SORT BY CHOSEN VARIABLE
         df=factor(levels=dataframes(eN))[[1]],                # Settings                      # data frame 
         sort.var=factor(NULL,levels=colnames(df))[[1]],       # Settings                      # variable to sort by  
         sort.order=factor("descending",levels=c("descending","ascending"))[[1]]     # Settings                      # Sort order, based on match  
) {
  tryCatch(
    {  
      result<-df
      result<-result[order(result[,sort.var], decreasing = (sort.order=="descending")),]
      result
    }, warning = function(w) { print(w); #return(data.frame(warning=as.character(w$message)))
      
    }, error = function(e) { print(e); err<-data.frame(error=as.character(e$message));err$error=as.character(err$error); return(err)
    
    }, finally = { 
      
    }
  )  
  
}

