string sorting in unix

Hi I need how to sort string characters

for Example i have a file that contains this data
example string "fan" but i want to display "afn" contained words
"afn" is in sorted format for fan.

File data

faty
gafny
gaifny
dafan
gafnniunt

O/p

gafny
gafnniunt

grep afn filename

Hey i know that grep afn filename.

but we dont know that afn is the string to be search..

if "hate" is the string then we need to search for "aeht"
if "hat" is the string then we need to search for "aht"

we need to search like this. please with the good answer

What have you tried to solve this problem.