Sort:  

Thanks @teamsteem, I appreciate it. It was a tricky one to write, but it's not too long.