0

I have this function :

  computed: { 
      availableSystems() {
         const availableSystems = this.systems.filter((sys) => sys && !sys?.active && sys?.enabled) || [];
         availableSystems.sort((a, b) => {
            if (a.name < b.name) { return -1; }
            if (a.name > b.name) { return 1; }
            return 0;
         });
         return availableSystems;
  },

But is not working as expected. I have the array of data whithout sort alphabetically. Have you an idea ? Thx in advance

GPiter
  • 779
  • 1
  • 11
  • 24
  • 2
    It would be hard to understand without sufficient data. I'd recommend to add more information... – DecPK Jun 24 '21 at 15:17
  • Is the `name` property defined? If a or b.name doesn't exist, it won't sort anything – GabrielMC Jun 24 '21 at 15:22
  • I also think you should consider breaking your question down to the absolute minimum amount of information needed to help you out. Consider reading: https://stackoverflow.com/help/minimal-reproducible-example If you consider your question, it has nothing to do with Vue js and the extra filter statement and conditions just adds noise that can make your question more difficult to answer. – RoboKozo Jun 24 '21 at 15:39

0 Answers0