Would it be useful to describe the sort key in the BIP to avoid ambiguity? for instance
Compute the PSBT_OUT_SCRIPT using the procedure in [https://github.com/bitcoin/bips/blob/master/bip-0352.mediawiki#creating-outputs BIP352] but substituting ''a·B<sub>scan</sub>'' with the PSBT_GLOBAL_SP_ECDH_SHARE for that scan key if available, or the sum of all PSBT_IN_SP_ECDH_SHAREs from eligible inputs for that scan key.
If there are multiple silent payment codes with the same scan key, sort the codes lexicographically in ascending order to determine the ordering of the ''k'' value.
+The sort key is the 66-byte serialized <tt>PSBT_OUT_SP_V0_INFO</tt> (33-byte scan key followed by 33-byte spend key).
If there are multiple silent payment codes with both the same scan and spend keys, sort the subgroup by output index in ascending order.
===Transaction Extractor===
or
====Computing the Output Scripts====
Compute the PSBT_OUT_SCRIPT using the procedure in [https://github.com/bitcoin/bips/blob/master/bip-0352.mediawiki#creating-outputs BIP352] but substituting ''a·B<sub>scan</sub>'' with the PSBT_GLOBAL_SP_ECDH_SHARE for that scan key if available, or the sum of all PSBT_IN_SP_ECDH_SHAREs from eligible inputs for that scan key.
-If there are multiple silent payment codes with the same scan key, sort the codes lexicographically in ascending order to determine the ordering of the ''k'' value.
-If there are multiple silent payment codes with both the same scan and spend keys, sort the subgroup by output index in ascending order.
+If there are multiple silent payment codes with the same scan key, assign the ''k'' values by sorting those codes in ascending order of their 66-byte serialized <tt>PSBT_OUT_SP_V0_INFO</tt> value (the concatenation of the 33-byte scan key and the 33-byte spend key). Break ties by ascending output index.
===Transaction Extractor===