diff --git a/src/Dataset.py b/src/Dataset.py
index a192474c67ec4ef3e8c24630fa2021c007103dc7..0c73fc74a8054b1e82ade6a2fa8ceaae8e4d7a2b 100644
--- a/src/Dataset.py
+++ b/src/Dataset.py
@@ -232,6 +232,9 @@ class Dataset:
         if type(colname) != str:
             logging.error("parameter `colname` is not a string")
             raise ValueError(f"{colname} is not a string")
+        if colname not in self.dataframe.columns:
+            logging.error("column requested not in dataframe")
+            raise KeyError(f"{colname} is not a column in dataframe")
         if not (ascending is None or type(ascending) is bool):
             logging.error("parameter `ascending` is not a bool or None")
             raise ValueError(f"{ascending} is not a bool or None")
diff --git a/src/test_dataset.py b/src/test_dataset.py
index be4d7437b6136e7e3b6d3e8300c90a9aae9c378b..7e7331ae07081df4d3a1f87625f7b36546806d5d 100644
--- a/src/test_dataset.py
+++ b/src/test_dataset.py
@@ -121,3 +121,4 @@ def test_catch_colname_not_in_df(the_dataset: Dataset):
     catch colnames not in dataset."""
     with pytest.raises(KeyError):
         the_dataset.get_category_counts("GAAAD_T")
+        the_dataset.get_sorted_column("GAAAD_T")