code: def sort_schemas(schemas):
      def keyfun(v):
          x = SQL_SCHEMA_REGEXP.match(v).groups()
          return (int(x[0]), x[1], int(x[2]) if x[2] else None,
                  x[3] if x[3] else 'zzz', int(x[4]))
      return sorted(schemas, key=keyfun)