This question evaluates string manipulation, custom ordering, stable reordering, and algorithmic complexity analysis with attention to space usage, placed in the Coding & Algorithms domain and focusing on practical algorithm design and implementation.

Given a priority string P of distinct characters and a text string S, reorder S so that all characters appearing in P come first and are grouped in the exact order specified by P, followed by all characters not in P while preserving their original relative order. Return the reordered string. Design an O(|P| + |S|) algorithm and discuss space usage. How would you adapt the solution for Unicode and for case-insensitive ordering?