Hello folks. I have a number of filters that need to be run on text. Sometimes order is important, sometimes it isn't. So, I need some way for users to arbitrarily order the filters. Some possibilities:
1. Assign each filter an integer weight, when the filter is added you stuff it in an array in an array, with the integer as the index
2. Assign each filter a float weight, the use array_multisort on a temporary array of all the filter's weights in order to get things in order
3. Require all filters to be specified at once, removing the need for weights
4. ???
What would you do?
Specifying filter order
Moderator: General Moderators
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Depending on your needs it might be enough to have add() that appends and another method to add to the front of the list. That often handles enough other cases to be sufficient. If the filters are named/grouped/typed then you can also have insertBefore() and insertAfter(), which I find more specific than weights.
(#10850)
- Maugrim_The_Reaper
- DevNet Master
- Posts: 2704
- Joined: Tue Nov 02, 2004 5:43 am
- Location: Ireland
Priority seems the simplest - is it possible to allow filters check their own priority in comparison to others? Depending on the filter, it might need to run before, but never after another to ensure the text remains readable. Having rules for such filters would make it more difficult to accidentally put them in the wrong order. insertBefore() and insertAfter() as suggested by arborint would be a cool way of applying such rules.Hello folks. I have a number of filters that need to be run on text. Sometimes order is important, sometimes it isn't. So, I need some way for users to arbitrarily order the filters. Some possibilities:
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK