Set-StrictMode -Version Latest
$str = [System.Collections.Generic.List[string]](
@(Get-Clipboard -Format Text -TextFormatType UnicodeText) -ne ""
)
Add-Type -Language CSharp -TypeDefinition @'
using System.Runtime.InteropServices;
namespace MyNamespace {
public class MyClass {
[DllImport(
"Shlwapi.dll", CharSet = CharSet.Unicode, EntryPoint = "StrCmpLogicalW"
)]
public static extern int StrCmpLogicalW(
[MarshalAs(UnmanagedType.LPWStr)] string psz1,
[MarshalAs(UnmanagedType.LPWStr)] string psz2
);
}
}
'@
$str.Sort(
[System.Delegate]::CreateDelegate(
[System.Comparison[string]], [MyNamespace.MyClass], "StrCmpLogicalW"
)
)
Write-Host ($str -join "`n")
$str -ne "" | Set-Clipboard