I have been searching for hours for a solution for my problem. I couldn't find anything quite like what I am trying to achieve., so I am really stuck and appreciate any help!

I have a CPT called "magazine", with several ACF fields. One ACF field is the "year" the magazine was published. Another field is the "magazine number", which is like an unique ID. Each year several magazines are published. 

What I am trying to achieve is an output, that gives me a "ul" element for every "year" and "li" elements for every "magazine number", that was published in the corresponding "year". 

For exmaple like this:

```
<ul class="2019">
   <li>200</li>
   <li>199</li>
   <li>198</li>
   <li>197</li>
   <li>196</li>
</ul>

<ul class="2018">
   <li>195</li>
   <li>194</li>
   <li>193</li>
   <li>192</li>
   <li>191</li>
</ul>

```

I have no idea, logic wise, how to approach this problem. How can I cross reference the fields, reduce all "year" field (which are several) to one output, and then output all "magazine number" published in the specific year and then output several lists for each year, as shown above?