0
$\begingroup$

I have another malformed list of football scores. Each score is reported in one of seven(!) possible formats, each which is sampled below:

lis = {{"Findlay", "FIN 45", " Lake Erie", "3"},
       {"Emporia State", "EMP 38", "0", " Northeastern State"},
       {"10", " Lincoln (MO)", "Washburn", "WASH 24"},
       {"SROS 27", " Sul Ross State", "Wayland Baptist", "7"},
       {" Washington & Jefferson","Westminster (PA)","WJC 48","3"}
       {" Alfred State College", "13", "Husson", "HUS 31"},
       {" Gallaudet", "10", "UNE 31", "University of New England"}}

As can be seen, each record contains an all-caps abbreviation of one of the teams involved, which may (or may not) be the first 3 or 4 letters of the school's full name.

The goal is to rearrange the list to give:

res = {{"Findlay","45","Lake Erie","3"}, 
       {"Emporia State","38","Northeastern State","0"}, 
       {"Lincoln (MO)","10","Washburn","24"}, 
       {"Sul Ross State","27","Wayland Baptist","7"}
       {"Washington & Jefferson","48","Westminster (PA)","3"}
       {"Alfred State College","13","Husson","31"}
       {"Gallaudet","10","University of New England","31"}}
        

Thanks for suggestions!

$\endgroup$
0

1 Answer 1

1
$\begingroup$

As far as I can tell, the answer I provided for your previous question also solves this one. (Note: as before you have missing commas in your data, which needs to be corrected before any of the solutions will work.)

Riffle @@@ 
  KeyValueMap[
    If[#1, Flatten[StringCases[#2, NumberString]], StringTrim[#2]] &] /@
      KeySort /@ (GroupBy[#, StringContainsQ[NumberString]] & /@ lis)

Unless you can explain the difference, this question should probably be deleted as a duplicate.

$\endgroup$
1
  • $\begingroup$ Yes you are right. Thanks. I tried to delete this question but it already has your response. $\endgroup$
    – Suite401
    Commented Sep 18, 2023 at 17:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.