sanitycheck: change distribution of tests per set

Sort by testcase name and path and not by platforms. This way we do not
have the same platform executing on CI system causing failures to
overload.

Right now we have almost all qemu targets executing on 1 or 2 nodes,
causing those systems to be overloaded. Instead of taking the default
sorting by platforms, we now sort by testcases, so the distribution is
more "random", but still reproducible.

Remove the ordering function that would put native_posix in the first
set, it is not being used anymore.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
diff --git a/scripts/sanitycheck b/scripts/sanitycheck
index d431ce3..f238cef 100755
--- a/scripts/sanitycheck
+++ b/scripts/sanitycheck
@@ -3152,7 +3152,7 @@
                           "rom_size"]
             cw = csv.DictWriter(csvfile, fieldnames, lineterminator=os.linesep)
             cw.writeheader()
-            for instance in sorted(self.instances.values()):
+            for instance in self.instances.values():
                 rowdict = {"test": instance.testcase.name,
                            "arch": instance.platform.arch,
                            "platform": instance.platform.name,
@@ -3810,23 +3810,6 @@
                 logger.info("{} can't be exported".format(test))
 
 
-def native_and_unit_first(a, b):
-    if a[0].startswith('unit_testing'):
-        return -1
-    if b[0].startswith('unit_testing'):
-        return 1
-    if a[0].startswith('native_posix'):
-        return -1
-    if b[0].startswith('native_posix'):
-        return 1
-    if a[0].split("/", 1)[0].endswith("_bsim"):
-        return -1
-    if b[0].split("/", 1)[0].endswith("_bsim"):
-        return 1
-
-    return (a > b) - (a < b)
-
-
 class HardwareMap:
 
     schema_path = os.path.join(ZEPHYR_BASE, "scripts", "sanity_chk", "hwmap-schema.yaml")
@@ -4276,8 +4259,9 @@
         return
 
     if options.subset:
-        # suite.instances = OrderedDict(sorted(suite.instances.items(),
-        #                    key=cmp_to_key(native_and_unit_first)))
+        suite.instances = OrderedDict(sorted(suite.instances.items(),
+                            key=lambda x: x[0][x[0].find("/") + 1:]))
+
         subset, sets = options.subset.split("/")
         total = len(suite.instances)
         per_set = round(total / int(sets))