I have a list of strings, as follows:
[https://test.com/id/51?nid=36202, https://test.com/id/513?nid=36202,
https://test.com/id/531?nid=39542, https://test.com/id/5645?nid=28502,
https://test.com/id/1233?nid=43812, https://test.com/id/7844?nid=43812,
https://test.com/id/54432?nid=44372,https://test.com/id/22185?nid=44372,
https://test.com/id/11063985?nid=44372, https://test.com/id/6110343?nid=8532, https://test.com/id/33218875?nid=26032]
For strings that end with the same NID, I want to group those together into one list of themselves within this larger list. So, eventually, it would be:
[[https://test.com/id/51?nid=36202, https://test.com/id/513?nid=36202],
[https://test.com/id/531?nid=39542], [https://test.com/id/5645?nid=28502],
[https://test.com/id/1233?nid=43812, https://test.com/id/7844?nid=43812],
[https://test.com/id/54432?nid=44372,https://test.com/id/22185?nid=44372,
https://test.com/id/11063985?nid=44372], [https://test.com/id/6110343?nid=8532],
[https://test.com/id/33218875?nid=26032]]
I've managed to get the top list sorted by using the built in sorted() feature in Python, but I cannot figure out how to group it the way I need it to be grouped. The NID can also be varying length, so I don't believe I can use a regular expression, but I'm also quite new to this and would appreciate any sort of help or suggestions anyone might be willing to offer.
Thank you!