Re: string parser

From: Victor Bazarov (v.Abazarov_at_comAcast.net)
Date: 08/18/04


Date: Wed, 18 Aug 2004 09:32:02 -0400

Raghavendra Mahuli wrote:
> I have many strings. I have to sort them. But sorting is not according to
> ascii but according to a different format (which keeps varying) . So i can
> sort them based on sort-order. It is not much of a problem.
>
> But the complex part is "equivalent-values". it can be defined that "ai" and
> "ae" are equivalent-values. Then, while sorting two strings, i have to
> consider that "ai" and "ae" are equal......only if they come at same
> position in both the strings....
> For EX1:
> str1 - dfahaesdhfkj
> str2 - dfahaisds
> In str1, ae appears at position 4 and 5
> In str2, ai appears also at position 4 and 5....
>
> So they are equivalent.....And i can replace ae in str1 with ai......
>
>
> EX2:
> str3 - haehasdg
> str4 - hhsdaiskdn
> In str3, ae appears at position 1 and 2
> In str4, ai appears also at position 4 and 5....
> So here the rule "equivalent -values" does not apply......So i cant replace
> "ae" in str3 with "ai".......
>
>
> In short, the "equivalent-values" applies only when the
> "position-matches"...
>
> To add to that such equivalent values are many......
> So can you please suggest me some way of solving this problem ....

First of all, this is not a language problem. Next time please post to
comp.programming if you need some kind of algorithm. Here you only post
if you have a C++ language problem/question/issue/interesting solution.

Second of all, if you do replace every 'ae' in both strings with 'ai',
it will change nothing WRT positional matches. Just try it and see.

Victor



Relevant Pages

  • Re: Solution for sorting an array alpha-numerically
    ... strings up into groups and sorting the groups seperately, ... > so that numeric and alphabetic data sort as seperate groups. ... To the same project as the web page, add the class AlphaNumCompare() ...
    (microsoft.public.dotnet.general)
  • Re: a question for sorting keys in Map
    ... I have a Map, actually a TreeMap, which will automatically sort the keys ... You can write your own Comparator object which implements the Compare ... strings so that X10 comes after X2 instead of before it. ... Unix ls command sort file names the way you want your strings to sort. ...
    (comp.lang.java.programmer)
  • Re: Detailed explanation of how a QuickSort Works
    ... Static player1 As Object ... But actually loading the data from the mp3 file from the disk and analyzing that data and decompressing it and arranging to stream it in a way that causes the song to be played through your speakers is a fairly complicated task, and almost all programmers will happily leave all that "knowledge" safely in the hands of the Player1 object and will treat it merely as a "black box" in the way I mentioned above. ... when sorting a large number of strings you will find it very much quicker to modify your sort routine so that it sorts "Long pointers" to the strings rather than sorting the string data itself. ...
    (microsoft.public.vb.general.discussion)
  • Re: fast stable sort
    ... Can you post C code for a stable in place mergesort function? ... How do you load a herd of strings into your ... diddles the pointers, not the strings. ... In this case the requirement is to sort the pointers in place ...
    (comp.programming)
  • One more "strlen" - was: Note to Chuck Crayne
    ... optimize strlen to shave one cycle off it, and you distribute your library to 1000 users, and they each write a program that uses strlen 1000 times, and distribute it to 1000 end-users, and they each run it ... We would of course only do strlen once per string, so we have to imagine we've got a lot of strings being thrown at us. ... When I click on the little hieroglyph to "sort by thread" instead of "sort by date", it takes - by wall clock - approximately a minute and fifteen seconds to complete. ... A better approach would be to keep a running index table for every column the user can sort by and every index table should be updated every time Thunderbird recieves an email/post...this way, the click on the glyph merrly selects which index table to use when picking what message headings to show in the window -- no need to run no freak'n algo. ...
    (alt.lang.asm)