Organize URLs by param

I need to sort the following list of URLs by considering the parameters:

Expected result:

I need to use awk to sort the URLs based on their parameters.

To sort the URLs based on their parameters using awk, you can use the following command:

awk -F'[?&]' -v OFS='?' '{gsub(/&/,RS); print | "sort"}' file.txt

Replace file.txt with the name of the file containing the URLs. This command uses awk to split each URL into separate parameters, sorts them using the sort command, and then prints the sorted URLs.

The expected result will be:

Note that the last URL in the expected result has the parameters one=1&two=2 instead of two=2&one=1 as mentioned in the question. This is because the sorting order is based on the parameters, not the order of appearance in the original URLs.