#SmileBASIC, 104104 81 bytes
DEF B AA@D
DIM T[LENSWAP A[0],A[RND(LEN(A))]FOR I=0TO LEN(A)-1T[I]=RNDF()IF I&&A[I-1]>A[I]GOTO@B2IF A[I]<A[I+1]GOTO@D
NEXT
RETURN@B
SORT T,A
B A
END
Explanation:
DEF BOGOSORT ARRAY[] 'create function
DIM TEMP[LEN(ARRAY)] 'create array used for scrambling
FOR I=0 TO LEN(ARRAY)-1 'loop through array
TEMP[I]=RNDF() 'fill TEMP with random numbers
IF I && ARRAY[I-1]>ARRAY[I] GOTO @BREAK 'if array is not sorted, exit the loop (skip check if I is 0)
NEXT
RETURN
@BREAK
SORT TEMP,ARRAY 'sort A using the random array
BOGOSORT ARRAY 'call the function again (much shorter than using a loop, but often causes a stack overflow)
END