Sorting a subset of stack of cards w/o sorting stack
Posted: Sun Apr 24, 2016 10:18 am
I am building a stack of cards sorted according to an index number with the form "YY-XXXX", where YY is the last two digits of the year, e.g., "98" for the year 1998 (the year of entry), and XXXX is the order of entry in the given year, e.g., "0001","0002", etc. This number is the first word of the card name and is also contained in a field on each card named "pcfnum". Users will create a new cards having any number between 47-XXXX (1947) and 16-XXXX (2016).
My script must put the new card in the correct position in the stack, e.g., a new user-created card with "98-0538" as the first word of its name (and the sole string in the fld "pcfnum") must be placed automatically between pre-existing cards "98-0222" and "98-1005". Bear in mind that in the stack there are other pre-existing cards for years both before and after 1998, including cards created in year 2000 and thereafter having as card names "00-XXXX", "01-XXXX", etc.
Being a beginner at this, the only method that has occurred to me is have the script (1) put the new card as the last card of the subset of the stack representing the cards of the given year, (2) mark all the cards of that subset by finding "YY-" in the fld "pcfnum", and (3) sort the marked cards by the fld "pcfnum". My hope was that just the marked cards would be sorted, leaving the position of all the unmarked cards unchanged, but the script not only correctly sorted the marked cards, but sorted the entire stack with the first cards being the "00-XXXX" and the last cards being "99-XXXX".
I couldn't find in this forum this kind of questions. Hoping there is a solution towards which I could be pointed, I pose the problem.
Monty
My script must put the new card in the correct position in the stack, e.g., a new user-created card with "98-0538" as the first word of its name (and the sole string in the fld "pcfnum") must be placed automatically between pre-existing cards "98-0222" and "98-1005". Bear in mind that in the stack there are other pre-existing cards for years both before and after 1998, including cards created in year 2000 and thereafter having as card names "00-XXXX", "01-XXXX", etc.
Being a beginner at this, the only method that has occurred to me is have the script (1) put the new card as the last card of the subset of the stack representing the cards of the given year, (2) mark all the cards of that subset by finding "YY-" in the fld "pcfnum", and (3) sort the marked cards by the fld "pcfnum". My hope was that just the marked cards would be sorted, leaving the position of all the unmarked cards unchanged, but the script not only correctly sorted the marked cards, but sorted the entire stack with the first cards being the "00-XXXX" and the last cards being "99-XXXX".
I couldn't find in this forum this kind of questions. Hoping there is a solution towards which I could be pointed, I pose the problem.
Monty