Use the Type field to determine which variant is active, then access the corresponding field:
switch providerPreferencesSort.Type { case components.ProviderPreferencesSortTypeProviderSort: // providerPreferencesSort.ProviderSort is populated case components.ProviderPreferencesSortTypeProviderSortConfig: // providerPreferencesSort.ProviderSortConfig is populated}