My solution in Haskell:
import Data.Char
-- Split a sentence into a list of words:
splitSentence :: String -> [String]
splitSentence s | (length w) == (length s) = [s]
| otherwise = w : (splitSentence (tail (dropWhile (/= ' ') s)))
where w = takeWhile (/= ' ') s
-- Order a lowercase word
orderWord :: String -> String
orderWord [x] = [x]
orderWord w | any (isAlphaNum) w = m : (orderWord (l ++ r))
| otherwise = w
where m = minimum (filter (isAlphaNum) w)
l = (takeWhile (/= m) w)
r = tail (dropWhile (/= m) w)
-- Make any characters that are evaluated next to a True upper case
makeUpper :: String -> [Bool] -> String
makeUpper [] _ = []
makeUpper (x:xs) (b:bs) | b = (toUpper x) : (makeUpper xs bs)
| otherwise = x : (makeUpper xs bs)
-- Order all words
orderWords :: [String] -> [String]
orderWords ss = map (\(a,b) -> makeUpper a b) m
where o = map (\x -> orderWord (map (toLower) x)) ss
c = map (\x -> map (isUpper) x) ss
m = zip o c
-- Order the sentence by splitting and ordering individual words
orderSentence :: String -> String
orderSentence = init . concat . map (++ [' ']) . orderWords . splitSentence
-- Get word from input:
main :: IO ()
main = do sentence <- getLine
let s = orderSentence sentence
putStrLn (show s)