Use stable sort with PVQ.

Cherry-pick Daala 85433214
 Fully order the pvq search candidates
For portable and stable sorting, break ties.
Large differences in output were observed between AWCY and an OS X
 machine because of the platform qsort implementation.

Change-Id: I294dd2e167c1e0464c7f61f32d60ab478341446e
diff --git a/av1/encoder/pvq_encoder.c b/av1/encoder/pvq_encoder.c
index b72e7ba..284b807 100644
--- a/av1/encoder/pvq_encoder.c
+++ b/av1/encoder/pvq_encoder.c
@@ -286,7 +286,9 @@
 } pvq_search_item;
 
 int items_compare(pvq_search_item *a, pvq_search_item *b) {
-  return a->k - b->k;
+  /* Break ties in K with gain to ensure a stable sort.
+     Otherwise, the order depends on qsort implementation. */
+  return a->k == b->k ? a->gain - b->gain : a->k - b->k;
 }
 
 /** Perform PVQ quantization with prediction, trying several