Sort problems.

Signed-off-by: David Symonds <dsymonds@golang.org>
diff --git a/lint.go b/lint.go
index c3e870e..dc8f807 100644
--- a/lint.go
+++ b/lint.go
@@ -15,6 +15,7 @@
 	"go/printer"
 	"go/token"
 	"regexp"
+	"sort"
 	"strconv"
 	"strings"
 	"unicode"
@@ -47,6 +48,27 @@
 	return p.Text
 }
 
+type byPosition []Problem
+
+func (p byPosition) Len() int      { return len(p) }
+func (p byPosition) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
+
+func (p byPosition) Less(i, j int) bool {
+	pi, pj := p[i].Position, p[j].Position
+
+	if pi.Filename != pj.Filename {
+		return pi.Filename < pj.Filename
+	}
+	if pi.Line != pj.Line {
+		return pi.Line < pj.Line
+	}
+	if pi.Column != pj.Column {
+		return pi.Column < pj.Column
+	}
+
+	return p[i].Text < p[j].Text
+}
+
 // Lint lints src.
 func (l *Linter) Lint(filename string, src []byte) ([]Problem, error) {
 	return l.LintFiles(map[string][]byte{filename: src})
@@ -126,7 +148,9 @@
 	for _, f := range p.files {
 		f.lint()
 	}
-	// TODO(dsymonds): sort?
+
+	sort.Sort(byPosition(p.problems))
+
 	return p.problems
 }