diff --git a/src/commands/palette.rs b/src/commands/palette.rs
index 167b541b2057f81aa534c8aa1687cc2caeb0b61a..bc6040f21eaeeefa95ea37eb1ce115d69d7458e4 100644
--- a/src/commands/palette.rs
+++ b/src/commands/palette.rs
@@ -21,9 +21,11 @@ pub fn sort_by_hue(palette: &mut PixelPalette) {
 		let hue_a = pa.hue();
 		let hue_b = pb.hue();
 
-		println!("A: {} vs B: {}", hue_a, hue_b);
-
-		if hue_a > hue_b {
+		if hue_a.is_nan() && hue_b.is_nan() {
+			Ordering::Equal
+		} else if hue_a.is_nan() {
+			Ordering::Less
+		} else if hue_b.is_nan() || hue_a > hue_b {
 			Ordering::Greater
 		} else if hue_b > hue_a {
 			Ordering::Less
diff --git a/src/utils.rs b/src/utils.rs
index 6dcebea575918615bcbcc56616e35fded1ddf504..edef97e1567ef32d88100ffda3625a586c67bb42 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -232,7 +232,7 @@ impl From<BasicLab> for Vec3 {
 impl UpperHex for BasicRgba {
 	fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
 		f.write_str(&format!(
-			"{:2X}{:2X}{:2X}{:2X}",
+			"{:02X}{:02X}{:02X}{:02X}",
 			self.r, self.g, self.b, self.a
 		))
 	}
@@ -240,7 +240,7 @@ impl UpperHex for BasicRgba {
 impl LowerHex for BasicRgba {
 	fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
 		f.write_str(&format!(
-			"{:2x}{:2x}{:2x}{:2x}",
+			"{:02x}{:02x}{:02x}{:02x}",
 			self.r, self.g, self.b, self.a
 		))
 	}