Improve TAB fretting algorithm.

An attempt to improve the current implementation to better deal with the case in forum post #29876 and possibly even with less specialized cases.

Changes:
- when a note changes of pitch, its fretting is discarded before any fretting
- each note not yet fretted is sorted for fretting as belonging to the string most convenient for it. This affects the order in which notes are evaluated during fretting.

Note: the algorithm can still be fooled by casual note entry and by changing note pitches by large intervals (octave), but it seems anyway better than before.
Merge pull request #1160 from mgavioli/Improve_tab_fretting_algorithm

Improve TAB fretting algorithm.