AnyDice: Second highest roll from mixed pool

I’m struggling to adapt Ilmari Karonen’s answers from these two questions to my problem.

I want to look at the second highest value from various pools.

function: max A:n B:n C:n {     result: 2@[sort {A, B, C}] } output [max 1d12 1d10 1d8] 

Produces possibly believable results, but:

output [max 2d12 0d10 0d8] 

Is not at all believable, and completely disagrees with:

output 2@2d12 

Similarly testing with

function: maxs A:n {     result: 2@[sort {A}] } output [maxs 2d12] 

hasn’t helped.