diff --git a/NAMESPACE b/NAMESPACE
index 88439a8fe3116874d2df7faa770a5b216314bb63..fe5d4c034947cad695147beec874b8d3bd1e1d4c 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -1,5 +1,6 @@
 # Generated by roxygen2: do not edit by hand
 
+export(concurrency)
 export(conf_trans)
 export(extr_data)
 export(extract)
@@ -9,8 +10,10 @@ export(load_compound_input)
 export(load_data_input)
 export(load_inputs)
 export(mk_comp_tab)
+export(mk_tol_funcs)
 export(prescreen)
 export(run)
 export(run_in_dir)
+export(sort_spectra)
 import(data.table)
 importFrom(shiny,validate)
diff --git a/R/api.R b/R/api.R
index 3cb675b2de8f0f41976927b24fc09f6f46a0b7e6..e011f542ac951803f9f990fa102d8bf8a9ecce19 100644
--- a/R/api.R
+++ b/R/api.R
@@ -172,7 +172,7 @@ verify_data <- function(conf,all_sets) {
     return(conf)
 }
 
-## @export
+#' @export
 concurrency <- function(m) {
     ## Reads the concurrency entry in the config. It is optional, if
     ## not given, then it is up to the user to define the plan of the
@@ -204,6 +204,7 @@ concurrency <- function(m) {
     m
 }
 
+#' @export
 mk_tol_funcs <- function(m) {
     ## Depending on units given when the user specified the errors,
     ## generate functions that calculate errors given the concrete
@@ -277,7 +278,7 @@ extr_data <- function(m) {
 
     msk <- sapply(tmp,future::resolved)
     curr_done <- which(msk)
-    names(msk) <- files
+    names(msk) <- ftags$Files
     
     for (x in curr_done) {
         message("Done extraction for ", names(msk)[[x]])
@@ -324,3 +325,13 @@ prescreen <- function(m) {
     m$out$tab$ftab <- merge(m$out$tab$comp,m$qa$ms[,..fields],by=c("Files","adduct","ID"))
     m
 }
+
+##' @export
+sort_spectra <- function(m) {
+    ## Sorts the spectral table (ftab) in order specified either in
+    ## `order spectra` sublist of m$conf, or if that is null, the
+    ## DEF_ORDER_SPECTRA.
+    order <- if (!is.null(m$conf[["order spectra"]])) m$conf[["order spectra"]] else DEF_ORDER_SPECTRA
+    data.table::setkeyv(m$out$tab$ftab,order)
+    m
+}
diff --git a/R/resources.R b/R/resources.R
index d62a74fad0d4fa86bc9b1d6a412f0de1f333d3ce..60c37f55675378d4fe634e025d96cf141b7cddce 100644
--- a/R/resources.R
+++ b/R/resources.R
@@ -183,3 +183,5 @@ QA_NUM_INT <- c("sel_ms2","ind_ms1_rt")
 
 QA_COLS <- c(QA_FLAGS,QA_NUM_REAL,QA_NUM_INT)
 
+## Default order of spectra in spectral table
+DEF_ORDER_SPECTRA <- c("set","qa_pass","int_ms1","adduct","mz","tag")