in perl it would be a simple test to see if the value existed in the hash and drop if it does not, however, this would be separate from the sort but still very simple and fast. <br><br>Andy<br><br>On Tuesday, November 29, 2011, James Courtier-Dutton <<a href="mailto:james.dutton@gmail.com">james.dutton@gmail.com</a>> wrote:<br>
> On 29 November 2011 22:36, David L Neil <<a href="mailto:GLLUG@getaroundtoit.co.uk">GLLUG@getaroundtoit.co.uk</a>> wrote:<br>>> James,<br>>><br>>>>>> Target pattern is a list of numbers in a certain predefined sequence.<br>
>>>>> The source data is a set of numbers that is always a subset of the<br>>>>>> predefined sequence.<br>>>>>> I need a way to sort the source data so that the numbers appear in the<br>
>>>>> same order as the predefined sequence.<br>>>>><br>>>>> What is the order of magnitude of the numbers in the source data set/in<br>>>>> the<br>>>>> predefined sequence?<br>
>>><br>>>> Magnitude is the input/predefined sequence is between 0 and 2^32.  I.e<br>>>> 0 to MAXINT32<br>>><br>>> =ouch!<br>>><br>>><br>>>>> How large/small a proportion of the predefined sequence is/are the source<br>
>>>> data set(s) likely to be?<br>>>><br>>>> The source sequence will always be shorter than the predefined<br>>>> sequence. Source is a subset of the predefined sequence.<br>>><br>
>> =understood from spec.<br>>><br>>> =a selection process is only likely to be more efficient than a sort as the<br>>> size of the sample (source) approaches the size of the population<br>>> (predefined sequence, or MAXINT32). Hence the question. Any idea of the<br>
>> ratio?<br>>><br>>><br>>>>> Is each record in the source unique with respect to the number in the set<br>>>>> or<br>>>>> may there be several with the same 'number',<br>
>>>> eg result may be 1 1 8 8 4 4 3 3 9 9<br>>>><br>>>> There should not be any duplicates in the source or predefined sequence.<br>>><br>>> =then efficient selection is possible...<br>
>><br>><br>> I have just thought of an edge case. If values in the source do not<br>> appear in the predefined sequence, I wish them to be dropped.<br>> I was planning to do some filtering on the source data to pre-drop the<br>
> values outside the predefined sequence, but if the sort algorithm can<br>> handle that at the same time, all the better.<br>> --<br>> Gllug mailing list  -  <a href="mailto:Gllug@gllug.org.uk">Gllug@gllug.org.uk</a><br>
> <a href="http://lists.gllug.org.uk/mailman/listinfo/gllug">http://lists.gllug.org.uk/mailman/listinfo/gllug</a><br>>