Zend certified PHP/Magento developer

Trying to understand an `awk` code [migrated]

I’m reading a book Effective AWK Programming by Arnold Robbins and I’ve come across this code there which I’m trying to understand.
It should sort this and similar lists, first all numeric items and then strings:

This first part is easy to understand

BEGIN {
data["one"] = 10
data["two"] = 20
data[10] = "one"
data[100] = 100
data[20] = "two"
f[1] = "cmp_num_idx"
f[2] = "cmp_str_val"
f[3] = "cmp_num_str_val"
for (i = 1; i <= 3; i++) {
printf("Sort function: %sn", f[i])
PROCINFO["sorted_in"] = f[i]
for (j in data)
printf("tdata[%s] = %sn", j, data[j])
print ""
}

}

However I have a problem to understand why at n2 == v2 it returns 1
and I do not follow even this last line

return (v1 < v2) ? -1 : (v1 != v2)

I do understand that if n2==v2 then v2 was a number and not a string!

So this is the problem:

function cmp_num_str_val(i1, v1, i2, v2, n1, n2)
{
# numbers before string value comparison, ascending order
n1 = v1 + 0
n2 = v2 + 0
if (n1 == v1)
return (n2 == v2) ? (n1 - n2) : -1
else if (n2 == v2)
return 1
return (v1 < v2) ? -1 : (v1 != v2)
} 

Can someone kindly explain to me the course of this code ?