From: Yohanes Santoso Date: 2006-07-19T12:21:15+09:00 Subject: Re: Integer encoding challenge "David Balmain" writes: > On 7/19/06, Yohanes Santoso wrote: >> "David Balmain" writes: >> >> > Hey all, >> > >> > I need to come up with a way to encode an integer as a string so that >> > it will sort correctly lexicographically. This is pretty easy when you >> > have a fixed integer range but how do you do it with Ruby's BigNums? >> > Any ideas? >> > >> > Cheers, >> > Dave >> >> def encode_integer(num) >> "x"*num >> end >> >> Do I win something? >> >> YS. > > Nice idea :P > But how about negative numbers. Same technique, but put them in different namespace. YS.