Sort in ascending and descending column by defined blocks of rows.

I am trying to sort column 2 considering blocks of 5 rows all time.
E.g.
First block rows 1 to 5 : Sort column 2 in ascending order
Second block rows 6 to 10 : Sort column 2 in descending order

Do this operation in all file

Input file

P 45683.00  39785.00 1 12 
P 45685.00  39785.00 1 12 
P 45687.00  39785.00 1 12 
P 45689.00  39785.00 1 12 
P 45691.00  39785.00 1 12 
P 45683.00  39795.00 1 12 
P 45685.00  39795.00 1 12 
P 45687.00  39795.00 1 12 
P 45689.00  39795.00 1 12 
P 45691.00  39795.00 1 12 
P 45683.00  39805.00 1 12 
P 45685.00  39805.00 1 12 
P 45687.00  39805.00 1 12 
P 45689.00  39805.00 1 12 
P 45691.00  39805.00 1 12 
P 45683.00  39815.00 1 12 
P 45685.00  39815.00 1 12 
P 45687.00  39815.00 1 12 
P 45689.00  39815.00 1 12 
P 45691.00  39815.00 1 12 

desired output

P 45683.00  39785.00 1 12 
P 45685.00  39785.00 1 12 
P 45687.00  39785.00 1 12 
P 45689.00  39785.00 1 12 
P 45691.00  39785.00 1 12 
P 45691.00  39795.00 1 12 
P 45689.00  39795.00 1 12 
P 45687.00  39795.00 1 12 
P 45685.00  39795.00 1 12 
P 45683.00  39795.00 1 12 
P 45683.00  39805.00 1 12 
P 45685.00  39805.00 1 12 
P 45687.00  39805.00 1 12 
P 45689.00  39805.00 1 12 
P 45691.00  39805.00 1 12 
P 45691.00  39815.00 1 12 
P 45689.00  39815.00 1 12 
P 45687.00  39815.00 1 12 
P 45685.00  39815.00 1 12 
P 45683.00  39815.00 1 12 

I tried

awk '/45691.00/{"awk \\$0+0==\\$0 "file | getline x}
{print x"~"FNR"~"$0 | "sort -k2,2n "}' 

Thanks in advance

Hi

vim -nes +'%!sort -bk3,3.5' +'6,11!sort -k2,2.6r' +'16,20!sort -k2,2.6r' +%p +q! file

If this is what you need change to the following and the file will be overwritten

vim -nes +'%!sort -bk3,3.5' +'6,11!sort -k2,2.6r' +'16,20!sort -k2,2.6r' +wq file

Try (untested):

awk '{print int((NR-1)/5), $0}' file | sort -k1,1n -k3,3 | cut -f2-

EDIT: the descending sort of every other block escaped me on first read. Try (still untested)

awk '{TMP = int((NR-1)/5); $2 = (TMP%2?"-":"") $2; print TMP, $0}' file1 | sort -k1,1n -k3,3g | awk '{sub (/-/, "", $3); sub ("^" $1 FS, "");} 1'