I am trying to create a crafting panel that sorts the list of items you can make alphabetically, yet I cannot figure out why .Sort() is not working.
What I have is a game object that holds a list of all the items you can make and the requirements, then in my crafting script I access the game object for the list and display the info.
Everything works fine until I try to sort anything. craftDatabase is what I need to be sorted. Also, it needs to be sorted by ItemID.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class CraftDatabase : MonoBehaviour
{
public List<Blueprint> craftDatabase = new List<Blueprint>();
}
[System.Serializable]
public class Blueprint
{
public string itemId;
public int itemAmount;
public float itemCraftTime = 1f;
public CraftPanel.subsections subsection;
public CraftPanel.workstations workStation;
public List<requiredItem> requiredItems = new List<requiredItem>();
[HideInInspector]
public string desc;
[System.Serializable]
public struct requiredItem
{
public string itemId;
public int itemAmount;
}
public Blueprint()
{
}
}
When I try to throw in craftDatabase.craftDatabase.Sort(); it gives me this error:
ArgumentException: does not implement right interface
How do I fix this error to use Sort()?
craftdatabasescript \$\endgroup\$Blueprintto see whySort()is not working) so as such, I am removing the additional examples to further clean up the question (debugging questions require a minimal viable example). \$\endgroup\$