Sort:  

correct, your formula looks a little bit complicate but it's right. My thoughts were 1² | 3² | 5² | 7² | 9² | 11² ;)

interesting. Don't quite understand why your algorithm equals mine, and unfortunately I'm too lazy to think about it at the moment ;)