diff --git a/cmd/tsdb/main.go b/cmd/tsdb/main.go
index 2fd67d54c9..bca446199a 100644
--- a/cmd/tsdb/main.go
+++ b/cmd/tsdb/main.go
@@ -23,6 +23,7 @@ import (
 	"path/filepath"
 	"runtime"
 	"runtime/pprof"
+	"sort"
 	"strings"
 	"sync"
 	"text/tabwriter"
@@ -317,8 +318,6 @@ func readPrometheusLabels(r io.Reader, n int) ([]labels.Labels, error) {
 	for scanner.Scan() && i < n {
 		m := make(labels.Labels, 0, 10)
 
-		// Order of the k/v labels matters, so rather than decoding arbitrary json into an
-		// interface{}, parse the line ourselves and remove unnecessary characters.
 		r := strings.NewReplacer("\"", "", "{", "", "}", "")
 		s := r.Replace(scanner.Text())
 
@@ -327,7 +326,8 @@ func readPrometheusLabels(r io.Reader, n int) ([]labels.Labels, error) {
 			split := strings.Split(labelChunk, ":")
 			m = append(m, labels.Label{Name: split[0], Value: split[1]})
 		}
-
+		// Order of the k/v labels matters, don't assume we'll always receive them already sorted.
+		sort.Sort(m)
 		h := m.Hash()
 		if _, ok := hashes[h]; ok {
 			continue
diff --git a/head_test.go b/head_test.go
index d0d51f550f..312f9ac326 100644
--- a/head_test.go
+++ b/head_test.go
@@ -18,6 +18,7 @@ import (
 	"fmt"
 	"math/rand"
 	"os"
+	"sort"
 	"strings"
 	"testing"
 
@@ -61,8 +62,6 @@ func readPrometheusLabels(fn string, n int) ([]labels.Labels, error) {
 	for scanner.Scan() && i < n {
 		m := make(labels.Labels, 0, 10)
 
-		// Order of the k/v labels matters, so rather than decoding arbitrary json into an
-		// interface{}, parse the line ourselves and remove unnecessary characters.
 		r := strings.NewReplacer("\"", "", "{", "", "}", "")
 		s := r.Replace(scanner.Text())
 
@@ -72,7 +71,8 @@ func readPrometheusLabels(fn string, n int) ([]labels.Labels, error) {
 			fmt.Println("split: ", split)
 			m = append(m, labels.Label{Name: split[0], Value: split[1]})
 		}
-
+		// Order of the k/v labels matters, don't assume we'll always receive them already sorted.
+		sort.Sort(m)
 		h := m.Hash()
 		if _, ok := hashes[h]; ok {
 			continue
diff --git a/labels/labels_test.go b/labels/labels_test.go
index aa9e0334ba..e57c5c29ff 100644
--- a/labels/labels_test.go
+++ b/labels/labels_test.go
@@ -135,8 +135,6 @@ func readPrometheusLabels(fn string, n int) ([]Labels, error) {
 	for scanner.Scan() && i < n {
 		m := make(Labels, 0, 10)
 
-		// Order of the k/v labels matters, so rather than decoding arbitrary json into an 
-		// interface{}, parse the line ourselves and remove unnecessary characters.
 		r := strings.NewReplacer("\"", "", "{", "", "}", "")
 		s := r.Replace(scanner.Text())
 
@@ -145,7 +143,8 @@ func readPrometheusLabels(fn string, n int) ([]Labels, error) {
 			split := strings.Split(labelChunk, ":")
 			m = append(m, Label{Name: split[0], Value: split[1]})
 		}
-
+		// Order of the k/v labels matters, don't assume we'll always receive them already sorted.
+		sort.Sort(m)
 		h := m.Hash()
 		if _, ok := hashes[h]; ok {
 			continue