function sortNotes(callback, key) {
  return function () {
    const sortedNotes = [...state.activeNotes];
    const indexPinNote = getIndexPinNote();
    // indexOf return -1 if no element in array
    if (state.pinNoteID && indexPinNote !== -1) {
      const pinnedNote = sortedNotes.splice(indexPinNote, 1);
      sortedNotes.sort(callback);
      sortedNotes.unshift(pinnedNote[0]);
    } else {
      sortedNotes.sort(callback);
    }
    state.currentNotesView = sortedNotes;
    state.currentSorting = key;
  };
}
// func takes callback and return new function with binded condition for sorting
func takes callback and return new function with binded condition for sorting
func takes callback and return new function with binded condition for sorting
function sortNotes(callback, key) {
  return function () {
    const sortedNotes = [...state.activeNotes];
    const indexPinNote = getIndexPinNote();
    if (state.pinNoteID && indexPinNote !== -1) {
      const pinnedNote = sortedNotes.splice(indexPinNote, 1);
      sortedNotes.sort(callback);
      sortedNotes.unshift(pinnedNote[0]);
    } else {
      sortedNotes.sort(callback);
    }
    state.currentNotesView = sortedNotes;
    state.currentSorting = key;
  };
}
function sortNotes ( callback , key ) { return function ( ) { const sortedNotes = [ ... state . activeNotes ] ; const indexPinNote = getIndexPinNote ( ) ; if ( state . pinNoteID && indexPinNote !== - 1 ) { const pinnedNote = sortedNotes . splice ( indexPinNote , 1 ) ; sortedNotes . sort ( callback ) ; sortedNotes . unshift ( pinnedNote [ 0 ] ) ; } else { sortedNotes . sort ( callback ) ; } state . currentNotesView = sortedNotes ; state . currentSorting = key ; } ; }
func takes callback and return new function with binded condition for sorting
func takes callback and return new function with binded condition for sorting
// indexOf return -1 if no element in array