Ranked Voting, Kanban? Other?

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.

Ideas? Other simpler methods?

Those “codes” are just random letters to assure that the kanban sorts alphabetically. If you look at my table below:

  • Status is my kanban categories.
  • Save Order is the order of the cards in each category.
  • I added a relation to get all rows with the same Status.
  • Then added a lookup column to get the Save Order as an array.
  • Then I sort the array alphabetically.
  • Then I get the index of the array.
  • Then I finally use a math column to add 1 to the zero based index number.

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.

image

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);
3 Likes

Glad to see those IDs are meaningful.

1 Like

They are.

@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?! :pray:

EDIT → It’s reversed…see below.

1 Like

Just to confirm, you are saying that this is sorted backwards compared to how the kanban sorts?

image

Yeah, I think you are correct.

Apologies…I think capitals do come before lower case…?

Hmm, I’m seeing mixed results. I’ll have to test this some more.

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.

That would be amazing. I’ve been trying to crack it. This is as far as I’ve gotten:

1 Like

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.

2 Likes

Interesting. How are you accounting for cards that have not yet been sorted? At that point they don’t have a save order right?

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?

Correct :confused: