3 Replies Latest reply on Apr 5, 2013 7:30 AM by mbraendle

    User Specific Sorts


      I am looking for the best way to allow for user specific sorting of a list. I have a list of users and their locations where each user needs to be able to sort by proximity to the other users.


      Here’s my example:


      Sam is from San Francisco; Dan is from Denver; and Chris is from Chicago.


      Sam sorts and gets, in order: Sam, Dan, Chris

      Dan sorts and gets, in order: Dan, Sam, Chris

      Chris sorts and gets, in order: Chris, Dan, Sam


      My best solution to date is use location specific fields with pre-calculated values. The file would then know who the user is (by account) and the user’s location and be able to sort on the proper field. The table looks like:


      User, Location, SanFrancisco_sort, Denver_sort, Chicago_sort



      Sam, San Francisco, 1, 2, 3

      Dan, Denver, 2, 1, 2

      Chris, Chicago, 3, 3, 1


      So, when Dan sorts, FM knows who he is and his location, then picks the right field to sort on (Denver_sort). When other users sort, they can get the right sort the same way and not interfere with any one else’s sort. (I don't think I can use a single sort field and calculate values on the fly because two users trying to sort at the same time would put different values in that field.)


      Does this make sense? Is there a better way to do this? While I can script the calculation for the values for those _sort fields (knowing the distances between cities), having a separate field for each location seems like too much. The actual list of users and locations is, of course, much larger.


      Ideas? Thoughts?




        • 1. Re: User Specific Sorts

          Your method sounds do-able...  Just wondering 'why?'


          - Lyndsay

          • 2. Re: User Specific Sorts

            I'd imagine the reason it's needed is because different user locations require records to be displayed in different priorities.


            As far as improving on your current method, I would suggest not using fields at all, and having a sort field that's calculated with a case statement based on account privilege. This way, you could create (or duplicate) a privilege set for each location, and calculate a single sort field based off that.


            IE assign users privileges:

            Sam is assigned privilege set "San Fransisco"

            Dan is assigned privilege set "Denver"


            And sort field calc:

            Case ( Get(AccountPrivilegeSetName) = "San Fransisco" ; "1" ;

                        Get(AccountPrivilegeSetName) = "Denver" ; "2";

            etc... )

            • 3. Re: User Specific Sorts

              You could store the LAT/LON coordinates with each user and then use the DistanceBetweenPoints custom function to calculate the distance between all user tuples:




              and use the distance to sort.


              The most efficient algorithm to choose depends much on the number n of users:


              - scaling linearly, distances unstored and calculated on the fly. May soon become slow since upon sorting must be recalculated.

              - scaling quadratically (more exactly: n*(n-1)/2), distances stored in a join table. But needs only to be calculated once, when a new user is added or when a user moves. Can be used immediately for sorting.


              Edit: Of course also the second algorithm scales linearly, but storage consumption scales quadratically.


              Message was edited by: MartinBraendle