Step 1: Break the absolute value function.
The absolute value function \( | \sin x - \cos x | \) can be written as:
\[
| \sin x - \cos x | =
\begin{cases}
\sin x - \cos x & \text{if } \sin x \geq \cos x
\cos x - \sin x & \text{if } \sin x<\cos x
\end{cases}
\]
To determine when \( \sin x = \cos x \), we solve \( \sin x = \cos x \), which gives:
\[
x = \frac{\pi}{4}
\]
Thus, we will split the integral at \( x = \frac{\pi}{4} \).
Step 2: Set up the integrals.
The integral becomes:
\[
I = \int_0^{\frac{\pi}{4}} (\cos x - \sin x) dx + \int_{\frac{\pi}{4}}^{\frac{\pi}{2}} (\sin x - \cos x) dx
\]
Step 3: Evaluate each integral.
The first integral:
\[
\int_0^{\frac{\pi}{4}} (\cos x - \sin x) dx = \sin x + \cos x \Big|_0^{\frac{\pi}{4}} = \sqrt{2} - 1
\]
The second integral:
\[
\int_{\frac{\pi}{4}}^{\frac{\pi}{2}} (\sin x - \cos x) dx = -\cos x - \sin x \Big|_{\frac{\pi}{4}}^{\frac{\pi}{2}} = \sqrt{2} - 1
\]
Step 4: Combine the results.
Adding both integrals together:
\[
I = (\sqrt{2} - 1) + (\sqrt{2} - 1) = 2(\sqrt{2} - 1)
\]
Step 5: Conclusion.
Thus, the value of the integral is:
\[
\boxed{2(\sqrt{2} - 1)}
\]
This matches option (B), which is the correct answer.