Hi Leeann, yes this is the expected functionality of the Wrk Action. Some functions only work when used on an array, if one of these functions is used on an Object then we pass the error message to the user as an ITC.
in order to make sure your input is always an array you can use the "Format outputs as an array?" boolean in WA-57 where you are creating the inbound_legs variable. This would require you to separate that variable out into its own WA if you don't want to update the output of the other two created variables.
Alternatively, as you mentioned, you could add a step that checks if it is an array before you attempt to sort it.