logo

live-bootstrap

Mirror of <https://github.com/fosslinux/live-bootstrap>

sorted.patch (1060B)


  1. SPDX-FileCopyrightText: 2022 fosslinux <fosslinux@aussies.space>
  2. SPDX-License-Identifier: PSF-2.0
  3. sorted() was only added in Python 2.5. But we are building Python 2.5.
  4. We cannot use .sort(), as it doesn't support the key= parameter.
  5. Instead we just use a basic custom selection sort to sort it ourselves
  6. using a custom key.
  7. --- Python-2.5.6/Tools/compiler/astgen.py.bak 2022-07-11 09:24:59.600238862 +1000
  8. +++ Python-2.5.6/Tools/compiler/astgen.py 2022-07-11 09:32:25.814974174 +1000
  9. @@ -215,7 +215,15 @@
  10. # some extra code for a Node's __init__ method
  11. name = mo.group(1)
  12. cur = classes[name]
  13. - return sorted(classes.values(), key=lambda n: n.name)
  14. + ret = classes.values()
  15. + # basic custom selection sort
  16. + for i in range(len(ret)):
  17. + min_i = i
  18. + for j in range(i + 1, len(ret)):
  19. + if ret[min_i].name > ret[j].name:
  20. + min_i = j
  21. + ret[i], ret[min_i] = ret[min_i], ret[i]
  22. + return ret
  23. def main():
  24. prologue, epilogue = load_boilerplate(sys.argv[-1])