You could do it recursively. To generate all the permutations of an n-character string, assuming all the characters are distinct, first generate all the permutations of an (n-1)-character string, make n copies of each permutation, and insert the n character in a different position in each copy.
String "abcd"
n=0:""
----
n=1:"a"
a
----
n=2:"ab"
ba
ab
----
n=3:"abc"
cba
bca
bac
cab
acb
abc
----
n=4:"abcd"
dcba
cdba
cbda
cbad
dbca
bdca
bcda
bcad
dbac
bdac
badc
bacd
dcab
cdab
cadb
cabd
dacb
adcb
acdb
acbd
dabc
adbc
abdc
abcd
There are faster iterative approaches based on minimum-change flips, but they're a bit trickier to code; but either way a systematic approach would be more robust than using bogosort.