diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4ba83d8..c57d74b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,12 @@
  * `msa` command for building multiple sequence alignments with
    [MUSCLE](https://drive5.com/muscle5/) ([#41])
 
+### Fixed
+
+ * `identity` command now uses a custom sequence ID column if one is given
+   ([#49])
+
+[#49]: https://github.com/ShawHahnLab/igseq/pull/49
 [#44]: https://github.com/ShawHahnLab/igseq/pull/44
 [#43]: https://github.com/ShawHahnLab/igseq/pull/43
 [#41]: https://github.com/ShawHahnLab/igseq/pull/41
diff --git a/igseq/data/examples/outputs/tree/example_pattern_from_newick.nex b/igseq/data/examples/outputs/tree/example_pattern_from_newick.nex
index 2485d4a..c2fd435 100644
--- a/igseq/data/examples/outputs/tree/example_pattern_from_newick.nex
+++ b/igseq/data/examples/outputs/tree/example_pattern_from_newick.nex
@@ -3,12 +3,12 @@ begin taxa;
 dimensions ntax=7;
 taxlabels
 'somethingelse'[&!color=#000000]
-'wk16-001'[&!color=#d186d7]
-'wk16-002'[&!color=#d186d7]
-'wk16-003'[&!color=#d186d7]
-'wk20-001'[&!color=#be4229]
-'wk20-002'[&!color=#be4229]
-'wk20-003'[&!color=#be4229]
+'wk16-001'[&!color=#be4229]
+'wk16-002'[&!color=#be4229]
+'wk16-003'[&!color=#be4229]
+'wk20-001'[&!color=#d186d7]
+'wk20-002'[&!color=#d186d7]
+'wk20-003'[&!color=#d186d7]
 ;
 end;
 
diff --git a/igseq/identity.py b/igseq/identity.py
index 24a47dd..8c80b11 100644
--- a/igseq/identity.py
+++ b/igseq/identity.py
@@ -58,7 +58,7 @@ def identity(path_in, path_out, path_ref=None, fmt_in=None, fmt_in_ref=None, col
                     record[reader.colmap["sequence"]],
                     ref[reader.colmap["sequence"]])
                 writer.write({
-                    "query": record["sequence_id"],
+                    "query": record[reader.colmap["sequence_id"]],
                     "ref": ref["sequence_id"],
                     "identity": score})
 
diff --git a/igseq/tree.py b/igseq/tree.py
index 9f61444..87f626c 100644
--- a/igseq/tree.py
+++ b/igseq/tree.py
@@ -286,6 +286,9 @@ def build_seq_sets(seq_ids, pattern=None, lists=None):
     if lists:
         for set_name, seq_set_ids in lists.items():
             seq_sets[set_name].update(seq_set_ids)
+    # Sort by key so we get a consistent order (yes, dicts are ordered these
+    # days)
+    seq_sets = {key: seq_sets[key] for key in sorted(seq_sets.keys())}
     return seq_sets
 
 def color_seqs(seq_ids, seq_sets, seq_set_colors=None):

diff --git a/test_igseq/data/test_identity/TestIdentityTabular/input_query.csv b/test_igseq/data/test_identity/TestIdentityTabular/input_query.csv
index e50c683..4708b06 100644
--- a/test_igseq/data/test_identity/TestIdentityTabular/input_query.csv
+++ b/test_igseq/data/test_identity/TestIdentityTabular/input_query.csv
@@ -1,4 +1,4 @@
-sequence_id,sequence,sequence2
-query1,ACTGACTGACTACTGG,CCAGTAGTCAGTCAGT
-query2,TCTGACCGACTACTGA,TCAGTAGTCGGTCAGA
-query3,ACAGACTGAGTACTGG,NNNNNNNNNNNNNNNN
+sequence_id,sequence_id2,sequence,sequence2
+query1,seqA,ACTGACTGACTACTGG,CCAGTAGTCAGTCAGT
+query2,seqB,TCTGACCGACTACTGA,TCAGTAGTCGGTCAGA
+query3,seqC,ACAGACTGAGTACTGG,NNNNNNNNNNNNNNNN
diff --git a/test_igseq/data/test_identity/TestIdentityTabular/output_col3.csv b/test_igseq/data/test_identity/TestIdentityTabular/output_col3.csv
new file mode 100644
index 0000000..ec8ac27
--- /dev/null
+++ b/test_igseq/data/test_identity/TestIdentityTabular/output_col3.csv
@@ -0,0 +1,4 @@
+query,ref,identity
+seqA,ref,1.0
+seqB,ref,0.8125
+seqC,ref,0.875
diff --git a/test_igseq/test_identity.py b/test_igseq/test_identity.py
index 9c4226e..fc7f544 100644
--- a/test_igseq/test_identity.py
+++ b/test_igseq/test_identity.py
@@ -103,9 +103,9 @@ class TestIdentityTabular(TestBase):
 
     def test_identity_columns(self):
         """Test using different columns from input."""
-        # Here a CSV query and CSV ref can give CSV output
-        # the defaults are the same as for convert() so sequence_id and
-        # sequence columns will be used.
+        # Here a CSV query and CSV ref can give CSV output.
+        # The defaults are the same as for convert() so sequence_id and
+        # sequence columns will be used unless overridden.
         with TemporaryDirectory() as tmpdir:
             identity(
                 self.path/"input_query.csv",
@@ -113,6 +113,13 @@ class TestIdentityTabular(TestBase):
                 self.path/"input_ref.csv",
                 colmap={"sequence": "sequence2"})
             self.assertTxtsMatch(self.path/"output_col2.csv", Path(tmpdir)/"output.csv")
+        with TemporaryDirectory() as tmpdir:
+            identity(
+                self.path/"input_query.csv",
+                Path(tmpdir)/"output.csv",
+                self.path/"input_ref.csv",
+                colmap={"sequence_id": "sequence_id2"})
+            self.assertTxtsMatch(self.path/"output_col3.csv", Path(tmpdir)/"output.csv")
 
     def test_identity_single(self):
         """Identity with implicit ref via query."""

identity command ignores sequence ID column name for tabular input
The identity command uses a hardcoded reference to the `sequence_id` column and ignores any custom column like from `--col-seq-id`.  (The existing tests check a custom sequence column, which works, but not a custom sequence ID column, which evidently doesn't.)
test_igseq/test_identity.py::TestIdentityTabular::test_identity_columns
test_igseq/test_identity.py::TestIdentity::test_identity test_igseq/test_identity.py::TestIdentity::test_identity_aa test_igseq/test_identity.py::TestIdentity::test_identity_csvgz_out test_igseq/test_identity.py::TestIdentity::test_identity_dryrun test_igseq/test_identity.py::TestIdentity::test_identity_single test_igseq/test_identity.py::TestIdentity::test_identity_stdout test_igseq/test_identity.py::TestIdentityTabular::test_identity test_igseq/test_identity.py::TestIdentityTabular::test_identity_single test_igseq/test_identity.py::TestScoreIdentity::test_score_identity test_igseq/test_identity.py::TestScoreIdentity::test_score_identity_objs