Sorting HELP

Hi, I have posted related topic but as i continue the research I find more need to sort the data.

AS(2607:f278:4101:11:dead:beef:f00f:f), AS786 AS6453 AS7575 AS7922    
AS(2607:f2e0:f:1db::16), AS786 AS3257 AS36252     
AS786 AS3257 AS36252      
AS(2607:f2f8:1700::2), AS786 AS6939 AS25795     
AS(2607:f388:e:0:218:8bff:fe23:786d), AS786 AS20965      
AS(2607:f4e8:12:fffe:230:48ff:fe96:f99e), AS786 AS3257      
AS(2607:f558:1000:f::42), AS786 AS20965      
AS(2607:f590:0:ffff::f1), AS786 AS6453      
AS(2001:1900:4:1::95) AS(2607:f728::), AS786 AS3356 AS6453 AS30496   
AS(2607:f740:0:d::2), AS786 AS6939      

Please I need help in sorting the above data to output only the IPs and each corresponding ASnumber on each line(bearing in mind that some IPs have longer AS number than each other), like this;

2001:1900:4:1::95 AS786 AS3356 AS6453 AS30496
2607:f740:0:d::2 AS786 AS6939

Thanks a lot for your anticipated help

What is the final expected output from the above sample?

The. Outcome are the others lIsted below the first set.thanks

Please, am still waiting for your help .thanks

Not sure, if I understand your request.

awk -F[\(\),] '/\(/{split($2,a,":");b[a[1]]=$2 $NF}END {for (i in b) print b}' urfile

Hi, I think you must have mistaken my request please; These are the format of what I need to be sorted (its a long list but these are just few lines from the list);
AS(2607:f278:4101:11:dead:beef:f00f:f), AS786 AS6453 AS7575 AS7922
AS(2607:f2e0:f:1db::16), AS786 AS3257 AS36252
AS786 AS3257 AS36252
AS(2607:f2f8:1700::2), AS786 AS6939 AS25795
AS(2607:f388:e:0:218:8bff:fe23:786d), AS786 AS20965
AS(2607:f4e8:12:fffe:230:48ff:fe96:f99e), AS786 AS3257
AS(2607:f558:1000:f::42), AS786 AS20965
AS(2607:f590:0:ffff::f1), AS786 AS6453
AS(2001:1900:4:1::95) AS(2607:f728::), AS786 AS3356 AS6453 AS30496
AS(2607:f740:0:d::2), AS786 AS6939

Then, I want the output to be in the format for all of the above;
2607:f278:4101:11:dead:beef:f00f:f AS786 AS6453 AS7575 AS7922
2607:f2e0:f:1db::16 AS786 AS3257 AS36252
AS786 AS3257 AS36252
2607:f2f8:1700::2 AS786 AS6939 AS25795
2607:f388:e:0:218:8bff:fe23:786d AS786 AS20965
2607:f4e8:12:fffe:230:48ff:fe96:f99e AS786 AS3257
2607:f558:1000:f::42 AS786 AS20965
2607:f590:0:ffff::f1 AS786 AS6453
2001:1900:4:1::95 AS786 AS3356 AS6453 AS30496
2607:f740:0:d::2 AS786 AS6939

Thanks you.

awk -F , '{if (NF==1) {print $0} else {gsub(/AS\(/,"");gsub(/\)/,"");split($1,a," ");print a[1],$2}}' urfile