Sorts the sources. The idea is that all Steven Black's list, file or entries get on top and the rest sorted alphabetically. Parameters ---------- sources: list The sources to sort.
(sources)
| 493 | |
| 494 | |
| 495 | def sort_sources(sources): |
| 496 | """ |
| 497 | Sorts the sources. |
| 498 | The idea is that all Steven Black's list, file or entries |
| 499 | get on top and the rest sorted alphabetically. |
| 500 | |
| 501 | Parameters |
| 502 | ---------- |
| 503 | sources: list |
| 504 | The sources to sort. |
| 505 | """ |
| 506 | |
| 507 | result = sorted( |
| 508 | sources.copy(), |
| 509 | key=lambda x: x.lower().replace("-", "").replace("_", "").replace(" ", ""), |
| 510 | ) |
| 511 | |
| 512 | # Steven Black's repositories/files/lists should be on top! |
| 513 | stevenblackpositions = [ |
| 514 | x for x, y in enumerate(result) if "stevenblack" in y.lower() |
| 515 | ] |
| 516 | |
| 517 | for index in stevenblackpositions: |
| 518 | result.insert(0, result.pop(index)) |
| 519 | |
| 520 | return result |
| 521 | |
| 522 | |
| 523 | # Exclusion logic |
no outgoing calls