I’m trying to make a Ranked Voting function. Let user pick 5 items from a list of many, then let user order them from 1 to 5. Most preferred, to least preferred. I will assign a weighting based on that order.
But I’m struggling to achieve this order in the editor to then assign a weighting for calculation. KanBan seems the easiest way on the user side to drag/reorder. But it gives those weird alpha-numeric codes in the editor. If I could convert the codes to simple numbers, it would help. Can’t figure how.
Another method with a few less columns is to keep the same relation (if you need it), replace the lookup with a joined list, and then use a bit of javascript to get the index.
function getIndexFromList(list, value) {
// Convert the comma-delimited list to an array and trim any whitespace from the items
const array = list.split(',').map(item => item.trim());
// Sort the array alphabetically
array.sort();
// Find the 1-based index of the value in the sorted array
const index = array.indexOf(value);
// Return the 1-based index if the value exists, otherwise return -1
return index !== -1 ? index + 1 : -1;
}
return getIndexFromList(p1, p2);
@Jeff_Hager — I found that the sort is ASCII where lower case is sorted before upper case, so Vxy comes before VXy comes before VXY. Does the sort in your code handle this?!
I’ve tried various sorting methods against different arrays, but with my sample data I’m not getting consistent results that match what you are showing and what I’m observing in my own kanban. I slightly changed the Save Order value for one of my cards and it moved in the kanban board, but didn’t affect my array sorting.
So far the basic alphabetic sort is working for me, but I totally understand what you are saying and I think I agree that it’s using ASCII somehow. Just haven’t figured out the pattern yet. I’ll continue to monitor the numbers as I use my kanban board and see if it breaks at some point in the future. If I understood how the save values were created in the first place, I think it would be easier to reverse engineer the sort order. If someone from Glide wants to provide a clue, it would be much appreciated.
I’ve been monitoring my Kanban board over the past week as I’ve added cards and moved them around. So far sorting still seems to be the alphabetical. Still don’t understand how the Save Order values are assigned, but so far my numbering based on alphabetical sort order has been accurate.
However, I did notice one peculiarity today. I moved one of my cards from ‘In Review’ to ‘With Support’ and it got assigned a Save Order value that already exists in the same group. Because of that my numbering put a #1 on both cards. The array has 2 items, but they both have the same value. Seems like a bit of a one-off, and when I move the cards around again, they correct themselves. Kind of interesting though. Still keeping an eye on it.
As soon as I add a card via the + button at the top of each category, it looks like the new card is assigned a Save Order value automatically, and is sorted to the top of the category. It’s not ideal since it adds an empty card and I need to edit it afterwards, but for my use it’s fine. I assume you add cards via a separate form?