Sort-Object -descend working backwards when packaged to exe

I’ve got the below code that when run as a powershell script on my system returns an interface index for the lowest interface metric default route in Get-NetRoute. The issue I am seeing is that when I run this as a PS1, it grabs the correct value, when I package it and run the exe, I get the opposite value I expect. I did some output checking in both and it appears the -descending flag is working backwards when I run the exe vs the ps1. Has anyone seen anything like this, and is there possibly anything to do besides remove the flag and let it run that way when I package(that provides the right value in exe)?

Code block:
primaryInterfaceIndex = Get-NetRoute | Where-Object {_.DestinationPrefix -eq “”} | Sort-Object -Property ifMetric -Descending | Select-Object -Last 1 -ExpandProperty ifIndex

$primaryInterfaceName = Get-NetAdapter -InterfaceIndex $primaryInterfaceIndex | Select-Object -ExpandProperty Name

$IPAddress = Get-NetIPAddress -InterfaceIndex $primaryInterfaceIndex -AddressFamily IPv4 | Select-Object -ExpandProperty IPAddress
$MACAddress = Get-NetAdapter -InterfaceIndex $primaryInterfaceIndex | Select-Object -ExpandProperty MacAddress