From: Ron Jeffries Date: 2002-03-17T19:58:49+09:00 Subject: Re: sorting large string of records On Sun, 17 Mar 2002 02:45:04 GMT, "Rich Kilmer" wrote: >How about this: > >class StringView > attr :offset > > def initialize(data, offset, len) > @data = data > @offset = offset > @len = len > end > > def <=>(other) > @len.times do |i| > case @data[@offset+i]<=>@data[other.offset+i] > when -1 > return -1 > when 1 > return 1 > end > end > return 0 > end > > def to_s > return @data[@offset, @len] > end >end Hi Rich ... I think this is logically correct, yes. The concern is that the @data[@offset+i] stuff creates a character object on each execution, as far as I know. As a sketch implementation for a method later to be written in C, this would work. But I didn't even want to instantiate the individual /rows/ of the database, let alone all the characters. Do you see my dilemma? Thanks, Ronald E Jeffries http://www.XProgramming.com http://www.objectmentor.com I'm giving the best advice I have. You get to decide whether it's true for you.