in reply to Re: sorting a vec
in thread sorting a vec

No, I mean a vec like "5583950372654" and I want to sort it to "02345556789". I have a file of integers that I am putting into a vec because an array will not fit them all. I actually then need to sort this vec based on values of another vec. But regardless of that, I was curious if there was a more 'perl' way to sort a vec but without converting it to an array first because of memory problems. I can do this through creating my own sort function and have done using insertion, substitution and quicksort (just to see which was truely better) but I was curious if there was another way to do this. No, not a homework assignment unfortunetly :)

Replies are listed 'Best First'.
Re: Re: Re: sorting a vec
by graff (Chancellor) on Nov 02, 2003 at 16:25 UTC
    Okay, I'll confess I'm no whiz at using bit vectors in perl, but I still find your question confusing, and I think you need to provide more information (or be more careful about what you're trying to say). In your example, it looks like the output of the sort is shorter than the input, but the truncation is inconsistent: the input has a couple of "3"s, where the output has one "3"; the input has four "5"s, where the output has three of them.

    How many bits make up each element of the bit vector string?

    If your real goal is to sort the integer values in one big file based on the integer values in some other big file, there are probably better ways to do this than trying to cram all that data into memory as bit vectors. But I wouldn't hazard a guess about that, since I still don't quite get what you're after.

    (For that matter, if you have already solved the problem by other means, and are just fishing for some different way to do it, that still strikes me as being more like homework, even if you aren't doing it for a grade.)

      I have found a few different ways, I have been doing my homework. I have implemented a couple different sorting algorithms to determine which one is the fastest given my problem. I also relize that there may be a way to sort vecs that is inherent in Perl that I am not aware of, for I am not a perl monk. Hence my posting. Does anyone know a way to sort a vec without converting it to an array. I apologize if this is confusing.