Reorder characters by a custom priority order with stable sorting.
Constraints
Example
>>> custom_sort_string("cba", "abcd")
'cbad'
>>> custom_sort_string("kqep", "pekeq")
'kqeep'
>>> custom_sort_string("abc", "cba")
'cb'? Wait "cba" has a,b,c? Actually order abc, s=cba -> all characters in order, so return 'abc'? Let's see: order 'abc', s 'cba' -> expected 'abc'? That is not stable? Actually the definition: characters that appear in order are placed first in order of order; all others appended stable. Here all characters appear in order, so return 'abc'.
>>> custom_sort_string("", "abc")
'abc'
Recent Submissions
No submissions yet — hit Run Tests to try!
Hints