sorting in awk

i have following file have following type of data

1~%%~fcashfafh~%%~9797

can i sort(numeric) the file on first field and then on last feild using awk

pipe it to |sort -n

sort -t"~" -kn1 -kn5 file

sort -nt "~" -k1,k5 file