How can I refactor to avoid repetition finding the index of strings in a list?
Let's start with a simpler problem where there's just one choice:

for (var i = 0; i &lt; compressors.Count; i++)
{
    if (compressors[i].StartsWith(firstChoice, StringComparison.OrdinalIgnoreCase))
    {
        return i;
    }
}

return 0;


(I would much prefer returning -1 if no match is found, but requirements are requirements.)

Now we can build on top of this to deal with the second preference:

var secondChoiceIndex = -1;
for (var i = 0; i &lt; compressors.Count; i++)
{
    if (compressors[i].StartsWith(firstChoice, StringComparison.OrdinalIgnoreCase))
    {
        return i;
    }

    if (secondChoiceIndex == -1 &amp;&amp; compressors[i].StartsWith(secondChoice, StringComparison.OrdinalIgnoreCase))
    {
        secondChoiceIndex = i;
    }
}

return secondChoiceIndex == -1 ? 0 : secondChoiceIndex;